X3D Model Documentation: CameraPrototypes.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2  <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN" "https://www.web3d.org/specifications/x3d-3.2.dtd">
  3  <X3D profile='Immersive' version='3.2 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.2.xsd'>
  4       <head>
  5            <meta name='titlecontent='CameraPrototypes.x3d'/>
  6            <meta name='descriptioncontent='Camera, CameraShot and CameraMovement prototypes that demonstrate storyboard capabilities and precise camera operation. This is a developmental effort for potential X3D Specification improvement.'/>
  7            <meta name='creatorcontent='Don Brutzman and Jeff Weekley'/>
  8            <meta name='createdcontent='16 March 2009'/>
  9            <meta name='modifiedcontent='20 January 2020'/>
 10            <meta name=' TODO content=' Schematron rules, backed up by initialize() checks '/>
 11            <meta name='referencecontent='BeyondViewpointCameraNodesWeb3D2009.pdf'/>
 12            <meta name='referencecontent='https://www.web3d.org/x3d/specifications/ISO-IEC-FDIS-19775-1.2-X3D-AbstractSpecification/Part01/components/navigation.html'/>
 13            <meta name='subjectcontent='Camera nodes for Viewpoint navigation control'/>
 14            <meta name='referencecontent='CameraExamples.x3d'/>
 15            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/Basic/development/CameraPrototypes.x3d'/>
 16            <meta name='referencecontent='http://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/development/CameraPrototypes.x3d'/>
 17            <meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
 18            <meta name='licensecontent='../license.html'/>
 19       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: CameraDirectionalLight, CameraMovementScript, CameraNavInfo, CameraOrientationInterpolator, CameraPositionInterpolator, CameraScript, CameraShotScript, CameraViewpoint, OfflineRenderScript

Index for Viewpoint nodes: Viewpoint_1, CameraViewpoint

Index for ProtoDeclare definitions: Camera, CameraMovement, CameraShot, OfflineRender
-->
 20       <Scene>
 21            <!-- =============== Camera ============== -->
 22            <WorldInfo title='CameraPrototypes.x3d'/>
 23            <ProtoDeclare name='Cameraappinfo='Camera node provides direct control of scene view to enable cinematic camera animation shot by shot and move by move along with still digital-photography settings for offline rendering of camera images.'>
 24                 <!-- Viewpoint-related fields, NavigationInfo-related fields and Camera-unique fields -->
 25                 <ProtoInterface>
 26                      <field name='descriptiontype='SFStringaccessType='inputOutput'
                     appinfo='Text description to be displayed for this Camera'/>
 27                      <field name='positiontype='SFVec3fvalue='0 0 10accessType='inputOutput'
                     appinfo='Camera position in local transformation frame, which is default prior to first CameraShot initialPosition getting activated'/>
 28                      <field name='orientationtype='SFRotationvalue='0 0 1 0accessType='inputOutput'
                     appinfo='Camera rotation in local transformation frame, which is default prior to first CameraShot initialPosition getting activated'/>
 29                      <field name='fieldOfViewtype='SFFloatvalue='0.7854accessType='inputOutput'
                     appinfo='pi/4'/>
 30                      <field name='set_fractiontype='SFFloataccessType='inputOnly'
                     appinfo='input fraction drives interpolators'/>
 31                      <field name='set_bindtype='SFBoolaccessType='inputOnly'
                     appinfo='input event binds or unbinds this Camera'/>
 32                      <field name='bindTimetype='SFTimeaccessType='outputOnly'
                     appinfo='output event indicates when this Camera is bound'/>
 33                      <field name='isBoundtype='SFBoolaccessType='outputOnly'
                     appinfo='output event indicates whether this Camera is bound or unbound'/>
 34                      <field name='nearClipPlanetype='SFFloatvalue='0.25accessType='inputOutput'
                     appinfo='Vector distance to near clipping plane corresponds to NavigationInfo.avatarSize[0]'/>
 35                      <field name='farClipPlanetype='SFFloatvalue='0.0accessType='inputOutput'
                     appinfo='Vector distance to far clipping plane corresponds to NavigationInfo.visibilityLimit'/>
 36                      <field name='shotstype='MFNodeaccessType='inputOutput'
                     appinfo='Array of CameraShot nodes which in turn contain CameraMovement nodes'>
 37                           <!-- initialization nodes (if any) go here -->
 38                      </field>
 39                      <field name='headlighttype='SFBoolvalue='trueaccessType='inputOutput'
                     appinfo='Whether camera headlight is on or off'/>
 40                      <field name='headlightColortype='SFColorvalue='1 1 1accessType='inputOutput'
                     appinfo='Camera headlight color'/>
 41                      <field name='headlightIntensitytype='SFFloatvalue='1accessType='inputOutput'
                     appinfo='Camera headlight intensity'/>
 42                      <field name='filterColortype='SFColorvalue='1 1 1accessType='inputOutput'
                     appinfo='Camera filter color that modifies virtual lens capture'/>
 43                      <field name='filterTransparencytype='SFFloatvalue='1accessType='inputOutput'
                     appinfo='Camera filter transparency that modifies virtual lens capture'/>
 44                      <field name='upVectortype='SFVec3fvalue='0 1 0accessType='inputOutput'
                     appinfo='upVector changes modify camera orientation (and possibly vice versa)'/>
 45                      <field name='fStoptype='SFFloatvalue='5.6accessType='inputOutput'
                     appinfo='Focal length divided effective aperture diameter indicating width of focal plane'/>
 46                      <field name='focusDistancetype='SFFloatvalue='10accessType='inputOutput'
                     appinfo='Distance to focal plane of sharpest focus'/>
 47                      <field name='isActivetype='SFBoolaccessType='outputOnly'
                     appinfo='Mark start/stop with true/false output respectively useful to trigger external animations'/>
 48                      <field name='totalDurationtype='SFTimeaccessType='outputOnly'
                     appinfo='Total duration of contained enabled CameraShot (and thus CameraMovement) move durations'/>
 49                      <field name='offlineRendertype='SFNodeaccessType='inputOutput'
                     appinfo='OfflineRender node'>
 50                           <!-- initialization node (if any) goes here -->
 51                      </field>
 52                      <field name='traceEnabledtype='SFBoolvalue='falseaccessType='initializeOnly'
                     appinfo='enable console output to trace script computations and prototype progress'/>
 53                 </ProtoInterface>
 54                 <ProtoBody>
 55 
                    <!-- Viewpoint CameraViewpoint is a DEF node that has 1 USE node: USE_1
                    <!-- ROUTE information for CameraViewpoint node:  [from CameraPositionInterpolator.value_changed to position ] [from CameraOrientationInterpolator.value_changed to orientation ] [from CameraScript.position to position ] [from CameraScript.orientation to orientation ] [from CameraScript.isActive to set_bind ] -->
                    <Viewpoint DEF='CameraViewpoint'>
 56                           <IS>
 57                                <connect nodeField='descriptionprotoField='description'/>
 58                                <connect nodeField='positionprotoField='position'/>
 59                                <connect nodeField='orientationprotoField='orientation'/>
 60                                <connect nodeField='fieldOfViewprotoField='fieldOfView'/>
 61                                <connect nodeField='set_bindprotoField='set_bind'/>
 62                                <connect nodeField='bindTimeprotoField='bindTime'/>
 63                                <connect nodeField='isBoundprotoField='isBound'/>
 64                           </IS>
 65                      </Viewpoint>
 66                      <!-- NavInfo EXAMINE used since some browsers (InstantReality) try to lock view to vertical when flying to avoid disorientation -->
 67 
                    <!-- NavigationInfo CameraNavInfo is a DEF node that has 1 USE node: USE_1
                    <!-- ROUTE information for CameraNavInfo node:  [from CameraScript.isActive to set_bind ] -->
                    <NavigationInfo DEF='CameraNavInfotype='"EXAMINE" "FLY" "ANY"'>
 68                           <IS>
 69                                <connect nodeField='set_bindprotoField='set_bind'/>
 70                                <!-- No need to bind outputs bindTime, isBound from NavigationInfo since Viewpoint outputs will suffice. TODO inform BitManagement that bindTime field is missing. -->
 71                                <connect nodeField='headlightprotoField='headlight'/>
 72                                <connect nodeField='visibilityLimitprotoField='farClipPlane'/>
 73                           </IS>
 74                      </NavigationInfo>
 75                      <!-- this DirectionalLight replaces NavigationInfo headlight in order to add color capability -->
 76 
                    <!-- ROUTE information for CameraDirectionalLight node:  [from CameraScript.isActive to on ] -->
                    <DirectionalLight DEF='CameraDirectionalLightglobal='true'>
 77                           <IS>
 78                                <connect nodeField='onprotoField='headlight'/>
 79                                <connect nodeField='colorprotoField='headlightColor'/>
 80                                <connect nodeField='intensityprotoField='headlightIntensity'/>
 81                           </IS>
 82                           <!-- TODO confirm other default field values match NavigationInfo spec -->
 83                      </DirectionalLight>
 84 
                    <!-- PositionInterpolator CameraPositionInterpolator is a DEF node that has 1 USE node: USE_1
                    <!-- ROUTE information for CameraPositionInterpolator node:  [from value_changed to CameraViewpoint.position ] -->
                    <PositionInterpolator DEF='CameraPositionInterpolatorkey='0 1keyValue='0 0 0 0 0 0'>
 85                           <IS>
 86                                <connect nodeField='set_fractionprotoField='set_fraction'/>
 87                           </IS>
 88                      </PositionInterpolator>
 89 
                    <!-- OrientationInterpolator CameraOrientationInterpolator is a DEF node that has 1 USE node: USE_1
                    <!-- ROUTE information for CameraOrientationInterpolator node:  [from value_changed to CameraViewpoint.orientation ] -->
                    <OrientationInterpolator DEF='CameraOrientationInterpolatorkey='0 1keyValue='0 1 0 0 0 1 0 0'>
 90                           <IS>
 91                                <connect nodeField='set_fractionprotoField='set_fraction'/>
 92                           </IS>
 93                      </OrientationInterpolator>
 94                      < ROUTE  fromNode='CameraPositionInterpolator' fromField='value_changed' toNode='CameraViewpoint' toField='position'/>
 95                      < ROUTE  fromNode='CameraOrientationInterpolator' fromField='value_changed' toNode='CameraViewpoint' toField='orientation'/>
 96 
                    <!-- ROUTE information for CameraScript node:  [from position to CameraViewpoint.position ] [from orientation to CameraViewpoint.orientation ] [from isActive to CameraViewpoint.set_bind ] [from isActive to CameraNavInfo.set_bind ] [from isActive to CameraDirectionalLight.on ] -->
                    <Script DEF='CameraScriptdirectOutput='truemustEvaluate='true'>
 97                           <!-- binding is controlled externally, all camera operations proceed the same regardless of whether bound or not -->
 98                           <field name='descriptiontype='SFStringaccessType='inputOutput'
                          appinfo='Text description to be displayed for this Camera'/>
 99                           <field name='positiontype='SFVec3faccessType='inputOutput'
                          appinfo='Camera position in local transformation frame'/>
100                           <field name='orientationtype='SFRotationaccessType='inputOutput'
                          appinfo='Camera rotation in local transformation frame'/>
101                           <field name='set_fractiontype='SFFloataccessType='inputOnly'
                          appinfo='input fraction drives interpolators'/>
102                           <field name='set_bindtype='SFBoolaccessType='inputOnly'
                          appinfo='input event binds or unbinds this Camera'/>
103                           <field name='fieldOfViewtype='SFFloataccessType='inputOutput'
                          appinfo='pi/4'/>
104                           <field name='nearClipPlanetype='SFFloataccessType='inputOutput'
                          appinfo='Vector distance to near clipping plane'/>
105                           <field name='farClipPlanetype='SFFloataccessType='inputOutput'
                          appinfo='Vector distance to far clipping plane'/>
106                           <field name='shotstype='MFNodeaccessType='inputOutput'
                          appinfo='Array of CameraShot nodes which in turn contain CameraMovement nodes'>
107                                <!-- initialization nodes (if any) go here -->
108                           </field>
109                           <field name='filterColortype='SFColoraccessType='inputOutput'
                          appinfo='Camera filter color that modifies virtual lens capture'/>
110                           <field name='filterTransparencytype='SFFloataccessType='inputOutput'
                          appinfo='Camera filter transparency that modifies virtual lens capture'/>
111                           <field name='upVectortype='SFVec3faccessType='inputOutput'
                          appinfo='upVector changes modify camera orientation (and possibly vice versa)'/>
112                           <field name='fStoptype='SFFloataccessType='inputOutput'
                          appinfo='Focal length divided effective aperture diameter indicating width of focal plane'/>
113                           <field name='focusDistancetype='SFFloataccessType='inputOutput'
                          appinfo='Distance to focal plane of sharpest focus'/>
114                           <field name='isActivetype='SFBoolaccessType='outputOnly'
                          appinfo='Mark start/stop with true/false output respectively useful to trigger external animations'/>
115                           <field name='totalDurationtype='SFTimeaccessType='outputOnly'
                          appinfo='Total duration of contained enabled CameraShot (and thus CameraMovement) move durations'/>
116                           <field name='offlineRendertype='SFNodeaccessType='inputOutput'
                          appinfo='OfflineRender node'>
117                                <!-- initialization node (if any) goes here -->
118                           </field>
119                           <field name='ViewpointNodetype='SFNodeaccessType='initializeOnly'
                          appinfo='node reference to permit getting setting fields from within Script'>
120                                <Viewpoint USE='CameraViewpoint'/>
121                           </field>
122                           <field name='NavInfoNodetype='SFNodeaccessType='initializeOnly'
                          appinfo='node reference to permit getting setting fields from within Script'>
123                                <NavigationInfo USE='CameraNavInfo'/>
124                           </field>
125                           <field name='CameraPItype='SFNodeaccessType='initializeOnly'
                          appinfo='node reference to permit getting setting fields from within Script'>
126                                <PositionInterpolator USE='CameraPositionInterpolator'/>
127                           </field>
128                           <field name='CameraOItype='SFNodeaccessType='initializeOnly'
                          appinfo='node reference to permit getting setting fields from within Script'>
129                                <OrientationInterpolator USE='CameraOrientationInterpolator'/>
130                           </field>
131                           <field name='keytype='MFFloataccessType='inputOutput'
                          appinfo='key array for interpolators'/>
132                           <field name='keyValuePositiontype='MFVec3faccessType='inputOutput'
                          appinfo='keyValue array for PositionInterpolator'/>
133                           <field name='keyValueOrientationtype='MFRotationaccessType='inputOutput'
                          appinfo='keyValue array for OrientationInterpolator'/>
134                           <field name='animatedtype='SFBoolvalue='falseaccessType='inputOutput'
                          appinfo='whether internal CameraShot and CameraMove nodes are tracking or changed via ROUTE events'/>
135                           <field name='initializedtype='SFBoolvalue='falseaccessType='initializeOnly'
                          appinfo='perform checkShots() function once immediately after initialization'/>
136                           <field name='shotCounttype='SFInt32value='0accessType='initializeOnly'
                          appinfo='how many CameraShot nodes are contained in shots array'/>
137                           <field name='movesCounttype='SFInt32value='0accessType='initializeOnly'
                          appinfo='how many CameraMove nodes are contained in moves array'/>
138                           <field name='frameCounttype='SFFloatvalue='0accessType='initializeOnly'
                          appinfo='how many frames were created in current loop'/>
139                           <field name='startTimetype='SFTimevalue='0accessType='initializeOnly'
                          appinfo='holding variable'/>
140                           <field name='priorTraceTimetype='SFTimevalue='0accessType='initializeOnly'
                          appinfo='holding variable'/>
141                           <field name='traceEnabledtype='SFBoolaccessType='initializeOnly'
                          appinfo='enable console output to trace script computations and prototype progress'/>
142                           <IS>
143                                <connect nodeField='descriptionprotoField='description'/>
144                                <connect nodeField='positionprotoField='position'/>
145                                <connect nodeField='orientationprotoField='orientation'/>
146                                <connect nodeField='set_fractionprotoField='set_fraction'/>
147                                <connect nodeField='set_bindprotoField='set_bind'/>
148                                <connect nodeField='fieldOfViewprotoField='fieldOfView'/>
149                                <connect nodeField='nearClipPlaneprotoField='nearClipPlane'/>
150                                <connect nodeField='farClipPlaneprotoField='farClipPlane'/>
151                                <connect nodeField='shotsprotoField='shots'/>
152                                <connect nodeField='filterColorprotoField='filterColor'/>
153                                <connect nodeField='filterTransparencyprotoField='filterTransparency'/>
154                                <connect nodeField='upVectorprotoField='upVector'/>
155                                <connect nodeField='fStopprotoField='fStop'/>
156                                <connect nodeField='focusDistanceprotoField='focusDistance'/>
157                                <connect nodeField='isActiveprotoField='isActive'/>
158                                <connect nodeField='totalDurationprotoField='totalDuration'/>
159                                <connect nodeField='offlineRenderprotoField='offlineRender'/>
160                                <connect nodeField='traceEnabledprotoField='traceEnabled'/>
161                           </IS>
  <![CDATA[
          
ecmascript:
function initialize () // CameraScript
{
//  tracePrint ('initialize start...');

    NavInfoNode.avatarSize[0]   = nearClipPlane;

    // remaining setups deferred to invocation of checkShots() method
    // thanks to Yvonne Jung Fraunhofer for diagnosing better approach to function initialization
    alwaysPrint ('initialize complete');
}

function checkShots (eventValue)
{
    tracePrint ('checkShots() method should only occur after initialize() methods in all other Scripts are complete');

    // compute totalDuration by summing durations from contained CameraShot and CameraMovement nodes
    totalDuration= 0;
    shotCount  = shots.length;
    movesCount = 0;
    for (i = 0; i < shotCount; i++) // shots index
    {
       tracePrint ('shots[' + i + '].moves.length=' + shots[i].moves.length);
       movesCount   += shots[i].moves.length;
       totalDuration = totalDuration + shots[i].shotDuration;
       if (shots[i].moves.length == 0)
       {
          alwaysPrint ('warning: CameraShot[' + i + '][' + shots[i].description + '] has no contained CameraMove nodes');
       }
    }
    // size checks before proceeding
    if (shotCount == 0)
    {
       alwaysPrint ('warning: no CameraShot nodes found for the shots, nothing to do!');
       return;
    }
    else if (movesCount == 0)
    {
       alwaysPrint ('warning: no CameraMove nodes found for the shots, nothing to do!');
       return;
    }
    else if (totalDuration == 0)
    {
       alwaysPrint ('warning: totalDuration = 0 seconds, nothing to do!');
       return;
    }
    tracePrint ('number of contained CameraShot nodes=' + shotCount);
    tracePrint ('number of contained CameraMove nodes=' + movesCount);
    tracePrint ('totalDuration=' + totalDuration + ' seconds for all shots and moves');

    // compute interpolators
    var k = 0; // index for latest key, keyValuePosition, keyValueOrientation
    for (i = 0; i < shotCount; i++) // shots index
    {
        if (i==0) // initial entries
        {
           key[0]                   = 0.0; // no previous move
           keyValuePosition[0]      = shots[i].initialPosition;
           keyValueOrientation[0]   = shots[i].initialOrientation;
        }
        else     // new shot repositions, reorients camera as clean break from preceding shot/move
        {
           key[k+1]                 = key[k]; // start from end from previous move
           keyValuePosition[k+1]    = shots[i].initialPosition;
           keyValueOrientation[k+1] = shots[i].initialOrientation;
           k++;
        }
        tracePrint (shots[i].description);
        tracePrint ('shots[i].moves.length=' + shots[i].moves.length);

        for (j = 0; j < shots[i].moves.length; j++) // moves index
        {
            var durationFloat =              shots[i].moves[j].duration;  // implicit type conversion from SFTime
            //  durationFloat = new SFFloat (shots[i].moves[j].duration); // explicit type conversion from SFTime
            //  tracePrint ('durationFloat=' + durationFloat);
            key[k+1]               = key[k] + (durationFloat / totalDuration);
            keyValuePosition[k+1]  = shots[i].moves[j].goalPosition;
            if (!animated)
            {
                 keyValueOrientation[k+1] = shots[i].moves[j].goalOrientation;
            }
            else
            {
                // using constructor SFRotation (SFVec3f fromVector, SFVec3f toVector)
                // see X3D ECMAScript binding Table 7.18 — SFRotation instance creation functions

                // test if difference vector is zero, if so maintain previous rotation
                var shotVector = ViewpointNode.position.subtract(shots[i].moves[j].goalAimPoint).normalize();
                if (shotVector.length() >= 0)
                {
                    // default view direction is along -Z axis
                    shots[i].moves[j].goalOrientation = new SFRotation (new SFVec3f (0, 0, 1), shotVector);
                    keyValueOrientation[k+1] = shots[i].moves[j].goalOrientation;
                }
                else // note (k > 0)
                {
                    keyValueOrientation[k+1] = keyValueOrientation[k];  // no change
                }

                tracePrint ('shots[' + i + '].moves[' + j + '].goalAimPoint=' + shots[i].moves[j].goalAimPoint.toString());
                tracePrint ('        ViewpointNode.position=' + ViewpointNode.position.toString());
                tracePrint ('          shotVector     delta=' + ViewpointNode.position.subtract(shots[i].moves[j].goalAimPoint).toString());
                tracePrint ('          shotVector normalize=' + ViewpointNode.position.subtract(shots[i].moves[j].goalAimPoint).normalize().toString());
                tracePrint ('               goalOrientation=' + shots[i].moves[j].goalOrientation.toString());
                tracePrint ('      keyValueOrientation[k+1]=' + keyValueOrientation[k+1].toString());
            }
            k++; // update index to match latest key, keyValuePosition, keyValueOrientation

            // check animated parameter:  set true if any of moves are tracking moves
            if (!animated)  animated = shots[i].moves[j].tracking; // once true, remains true
         // tracePrint ('shots[' + i + '].moves[' + j + '].tracking=' + shots[i].moves[j].tracking + ', animated=' + animated);

            // intermediate trace
            tracePrint ('                key=' + key);
            tracePrint ('   keyValuePosition=' + keyValuePosition);
            tracePrint ('keyValueOrientation=' + keyValueOrientation);
            tracePrint ('- ' + shots[i].moves[j].description);
        }
    }
    tracePrint ('                key=' + key);
    tracePrint ('   keyValuePosition=' + keyValuePosition);
    tracePrint ('keyValueOrientation=' + keyValueOrientation);
    if (key.length != keyValuePosition.length)
    {
      alwaysPrint ('warning: internal error during array construction, ' +
                  'key.length=' + key.length + ' must equal ' +
                  'keyValuePosition.length=' + keyValuePosition.length);
    }
    if (key.length != keyValueOrientation.length)
    {
      alwaysPrint ('warning: internal error during array construction, ' +
                  'key.length=' + key.length + ' must equal ' +
                  'keyValueOrientation.length=' + keyValueOrientation.length);
    }
    if (key.length != (shotCount + movesCount))
    {
      alwaysPrint ('warning: internal error during array construction, ' +
                  'key.length=' + key.length + ' must equal ' +
                  '(shotCount + movesCount)=' + (shotCount + movesCount));
    }
    tracePrint ('           animated=' + animated);
    // set node values
    CameraPI.key      = key;
    CameraOI.key      = key;
    CameraPI.keyValue = keyValuePosition;
    CameraOI.keyValue = keyValueOrientation;

    if (!animated) // output results
    {
        tracePrint ('<PositionInterpolator    DEF=\'CameraPositionInterpolator\'    key=\'' + stripBrackets(CameraPI.key) + '\' keyValue=\'' + stripBrackets(CameraPI.keyValue) + '\'/>');
        tracePrint ('<OrientationInterpolator DEF=\'CameraOrientationInterpolator\' key=\'' + stripBrackets(CameraOI.key) + '\' keyValue=\'' + stripBrackets(CameraOI.keyValue) + '\'/>');
    }
    tracePrint ('checkShots() complete');
}

function stripBrackets (fieldArray)
{
    // some browsers add brackets to array output strings, this function strips them
    outputString = '';
    for (i = 0; i < fieldArray.length; i++)
    {
       outputString += fieldArray[i].toString();
       if (i < fieldArray.length - 1) outputString += ' ';
    }
    return outputString;
}

function set_fraction (eventValue, timestamp) // input event received for inputOnly field
{
   // traceEnabled = false;  // for testing purposes

   // if Camera is being animated, immediately recompute interpolator settings
   if (animated) checkShots (true);

   // trace progress on console with reduced output frequency
   if (frameCount == 0)
   {
      alwaysPrint ('Animation loop commencing, timestamp=' + timestamp);
      startTime      = timestamp;
      priorTraceTime = timestamp;
      alwaysPrint ('shotClock=' + (timestamp - startTime) + ' seconds, frameCount=' + frameCount + ', fraction=' + eventValue + ', position=' + ViewpointNode.position.toString() + ', orientation=' + ViewpointNode.orientation.toString());

      if (animated) // output results
      {
        // TODO how to report or speed up response?  alwaysPrint ('  aimPoint=' + aimPoint.toString());
        tracePrint ('  <PositionInterpolator    DEF=\'CameraPositionInterpolator\'    key=\'' + stripBrackets(CameraPI.key) + '\' keyValue=\'' + stripBrackets(CameraPI.keyValue) + '\'/>');
        tracePrint ('  <OrientationInterpolator DEF=\'CameraOrientationInterpolator\' key=\'' + stripBrackets(CameraOI.key) + '\' keyValue=\'' + stripBrackets(CameraOI.keyValue) + '\'/>');
      }
   }
   else if ((timestamp - priorTraceTime) >= 1.0) // 1 second trace interval
   {
      alwaysPrint ('shotClock=' + (timestamp - startTime) + ' seconds, frameCount=' + frameCount + ', fraction=' + eventValue + ', position=' + ViewpointNode.position.toString() + ', orientation=' + ViewpointNode.orientation.toString());
      priorTraceTime = timestamp;

      if (animated) // output results
      {
        // TODO how to report or speed up response?  alwaysPrint ('  aimPoint=' + aimPoint.toString());
        tracePrint ('  <PositionInterpolator    DEF=\'CameraPositionInterpolator\'    key=\'' + stripBrackets(CameraPI.key) + '\' keyValue=\'' + stripBrackets(CameraPI.keyValue) + '\'/>');
        alwaysPrint ('  <OrientationInterpolator DEF=\'CameraOrientationInterpolator\' key=\'' + stripBrackets(CameraOI.key) + '\' keyValue=\'' + stripBrackets(CameraOI.keyValue) + '\'/>');
      }
   }
   if (eventValue == 0)
   {
      // note that zero value is not necessarily sent first by TimeSensor, so otherwise ignored
      frameCount++;
   }
   else if (eventValue == 1)
   {
      alwaysPrint ('shotClock=' + (timestamp - startTime) + ', frameCount=' + frameCount + ', fraction=' + eventValue + ', position=' + ViewpointNode.position.toString() + ', orientation=' + ViewpointNode.orientation.toString());
      if (animated) // output results
      {
        // TODO how to report or speed up response?  alwaysPrint ('  aimPoint=' + aimPoint.toString());
      }
      alwaysPrint ('Animation loop complete.');
      // do not unbind the Viewpoint and NavigationInfo nodes, let that be controlled externally
   }
   else
   {
      frameCount++;
   }
}

function set_bind (eventValue) // input event received for inputOnly field
{
   // need to ensure CameraShot nodes are properly initialized
   if (initialized == false)
   {
      checkShots (true);
      initialized = true;
   }
   if (eventValue)
   {
       tracePrint ('Camera has been bound');
   }
   else
   {
       tracePrint ('Camera has been unbound');
   }
}

function set_description (eventValue) // input event received for inputOutput field
{
    description = eventValue;
}

function set_position (eventValue) // input event received for inputOutput field
{
    position = eventValue;
}

function set_orientation (eventValue) // input event received for inputOutput field
{
    orientation = eventValue;
}

function set_fieldOfView (eventValue) // input event received for inputOutput field
{
    fieldOfView = eventValue;
}

function set_nearClipPlane (eventValue) // input event received for inputOutput field
{
    nearClipPlane = eventValue;
}

function set_farClipPlane (eventValue) // input event received for inputOutput field
{
    farClipPlane = eventValue;
}

function set_shots (eventValue) // input event received for inputOutput field
{
    shots = eventValue;
}

function set_filterColor (eventValue) // input event received for inputOutput field
{
    filterColor = eventValue;
}

function set_filterTransparency (eventValue) // input event received for inputOutput field
{
    filterTransparency = eventValue;
}

function set_upVector (eventValue) // input event received for inputOutput field
{
    upVector = eventValue;
}

function set_fStop (eventValue) // input event received for inputOutput field
{
    fStop = eventValue;
}

function set_focusDistance (eventValue) // input event received for inputOutput field
{
    focusDistance = eventValue;
}

function set_offlineRender (eventValue) // input event received for inputOutput field
{
    offlineRender = eventValue;
}

function set_key (eventValue) // input event received for inputOutput field
{
    key = eventValue;
}

function set_keyValuePosition (eventValue) // input event received for inputOutput field
{
    keyValuePosition = eventValue;
}

function set_keyValueOrientation (eventValue) // input event received for inputOutput field
{
    keyValueOrientation = eventValue;
}

function set_animated (eventValue) // input event received for inputOutput field
{
    animated = eventValue;
}

function tracePrint (outputValue)
{
	if (traceEnabled) alwaysPrint (outputValue);
}
function alwaysPrint (outputValue)
{
    // try to ensure outputValue is converted to string despite Browser.println idiosyncracies
    var outputString = outputValue.toString(); // utility function according to spec
    if (outputString == null) outputString = outputValue; // direct cast

    if  (description.length > 0)
         Browser.println ('[Camera: ' + description + '] ' + outputString);
    else
         Browser.println ('[Camera] ' + outputString);
}

        
]]>
163                      </Script>
164                      < ROUTE  fromNode='CameraScript' fromField='position' toNode='CameraViewpoint' toField='position'/>
165                      < ROUTE  fromNode='CameraScript' fromField='orientation' toNode='CameraViewpoint' toField='orientation'/>
166                      < ROUTE  fromNode='CameraScript' fromField='isActive' toNode='CameraViewpoint' toField='set_bind'/>
167                      < ROUTE  fromNode='CameraScript' fromField='isActive' toNode='CameraNavInfo' toField='set_bind'/>
168                      < ROUTE  fromNode='CameraScript' fromField='isActive' toNode='CameraDirectionalLight' toField='on'/>
169                 </ProtoBody>
170            </ProtoDeclare>
171            <!-- =============== CameraShot ============== -->
172            <ProtoDeclare name='CameraShotappinfo='CameraShot collects a specific set of CameraMovement animations that make up an individual shot.'>
173                 <ProtoInterface>
174                      <field name='descriptiontype='SFStringaccessType='inputOutput'
                     appinfo='Text description to be displayed for this CameraShot'/>
175                      <field name='enabledtype='SFBoolvalue='trueaccessType='inputOutput'
                     appinfo='Whether this CameraShot can be activated'/>
176                      <field name='movestype='MFNodeaccessType='inputOutput'
                     appinfo='Set of CameraMovement nodes'>
177                           <!-- initializing CameraMovement nodes are inserted here by scene author using ProtoInstance -->
178                      </field>
179                      <field name='initialPositiontype='SFVec3fvalue='0 0 10accessType='inputOutput'
                     appinfo='Setup to reinitialize camera position for this shot'/>
180                      <field name='initialOrientationtype='SFRotationvalue='0 0 1 0accessType='inputOutput'
                     appinfo='Setup to reinitialize camera rotation for this shot'/>
181                      <field name='initialAimPointtype='SFVec3fvalue='0 0 0accessType='inputOutput'
                     appinfo='Setup to reinitialize aimpoint (relative location for camera direction) for this shot'/>
182                      <field name='initialFieldOfViewtype='SFFloatvalue='0.7854accessType='inputOutput'
                     appinfo='pi/4'/>
183                      <field name='initialFStoptype='SFFloatvalue='5.6accessType='inputOutput'
                     appinfo='Focal length divided effective aperture diameter indicating width of focal plane'/>
184                      <field name='initialFocusDistancetype='SFFloatvalue='10accessType='inputOutput'
                     appinfo='Distance to focal plane of sharpest focus'/>
185                      <field name='shotDurationtype='SFTimeaccessType='outputOnly'
                     appinfo='Subtotal duration of contained CameraMovement move durations'/>
186                      <field name='isActivetype='SFBoolaccessType='outputOnly'
                     appinfo='Mark start/stop with true/false output respectively useful to trigger external animations'/>
187                      <field name='traceEnabledtype='SFBoolvalue='falseaccessType='initializeOnly'
                     appinfo='enable console output to trace script computations and prototype progress'/>
188                 </ProtoInterface>
189                 <ProtoBody>
190                      <Script DEF='CameraShotScriptdirectOutput='truemustEvaluate='true'>
191                           <field name='descriptiontype='SFStringaccessType='inputOutput'
                          appinfo='Text description to be displayed for this CameraShot'/>
192                           <field name='enabledtype='SFBoolaccessType='inputOutput'
                          appinfo='Whether this CameraShot can be activated'/>
193                           <field name='movestype='MFNodeaccessType='inputOutput'
                          appinfo='Set of CameraMovement nodes'>
194                                <!-- initialization nodes (if any) go here -->
195                           </field>
196                           <field name='initialPositiontype='SFVec3faccessType='inputOutput'
                          appinfo='Setup to reinitialize camera position for this shot'/>
197                           <field name='initialOrientationtype='SFRotationaccessType='inputOutput'
                          appinfo='Setup to reinitialize camera rotation for this shot'/>
198                           <field name='initialAimPointtype='SFVec3faccessType='inputOutput'
                          appinfo='Setup to reinitialize aimpoint (relative location for camera direction) for this shot'/>
199                           <field name='initialFieldOfViewtype='SFFloataccessType='inputOutput'
                          appinfo='pi/4'/>
200                           <field name='initialFStoptype='SFFloataccessType='inputOutput'
                          appinfo='Focal length divided effective aperture diameter indicating width of focal plane'/>
201                           <field name='initialFocusDistancetype='SFFloataccessType='inputOutput'
                          appinfo='Distance to focal plane of sharpest focus'/>
202                           <field name='shotDurationtype='SFTimeaccessType='outputOnly'
                          appinfo='Subtotal duration of contained CameraMovement move durations'/>
203                           <field name='isActivetype='SFBoolaccessType='outputOnly'
                          appinfo='Mark start/stop with true/false output respectively useful to trigger external animations'/>
204                           <field name='traceEnabledtype='SFBoolaccessType='initializeOnly'
                          appinfo='enable console output to trace script computations and prototype progress'/>
205                           <field name='keytype='MFFloataccessType='inputOutput'
                          appinfo='key array for interpolators'/>
206                           <field name='keyValuePositiontype='MFVec3faccessType='inputOutput'
                          appinfo='keyValue array for PositionInterpolator'/>
207                           <field name='keyValueOrientationtype='MFRotationaccessType='inputOutput'
                          appinfo='keyValue array for OrientationInterpolator'/>
208                           <IS>
209                                <connect nodeField='descriptionprotoField='description'/>
210                                <connect nodeField='enabledprotoField='enabled'/>
211                                <connect nodeField='movesprotoField='moves'/>
212                                <connect nodeField='initialPositionprotoField='initialPosition'/>
213                                <connect nodeField='initialOrientationprotoField='initialOrientation'/>
214                                <connect nodeField='initialAimPointprotoField='initialAimPoint'/>
215                                <connect nodeField='initialFieldOfViewprotoField='initialFieldOfView'/>
216                                <connect nodeField='initialFStopprotoField='initialFStop'/>
217                                <connect nodeField='initialFocusDistanceprotoField='initialFocusDistance'/>
218                                <connect nodeField='shotDurationprotoField='shotDuration'/>
219                                <connect nodeField='isActiveprotoField='isActive'/>
220                                <connect nodeField='traceEnabledprotoField='traceEnabled'/>
221                           </IS>
  <![CDATA[
          
ecmascript:
function initialize () // CameraShotScript
{
//  tracePrint ('initialize start...');

    // compute shotDuration by summing durations from contained CameraMovement nodes
    shotDuration = 0;
    for (i = 0; i < moves.length; i++)
    {
        shotDuration = shotDuration + moves[i].duration;
    }
    alwaysPrint ('number of contained CameraMove nodes=' + moves.length + ', shotDuration=' + shotDuration + ' seconds');

//  tracePrint ('... initialize() complete');
}

function set_description (eventValue) // input event received for inputOutput field
{
    description = eventValue;
}

function set_enabled (eventValue) // input event received for inputOutput field
{
    enabled = eventValue;
}

function set_moves (eventValue) // input event received for inputOutput field
{
    moves = eventValue;
}

function set_initialPosition (eventValue) // input event received for inputOutput field
{
    initialPosition = eventValue;
}

function set_initialOrientation (eventValue) // input event received for inputOutput field
{
    initialOrientation = eventValue;
}

function set_initialAimPoint (eventValue) // input event received for inputOutput field
{
    initialAimPoint = eventValue;
}

function set_initialFieldOfView (eventValue) // input event received for inputOutput field
{
    initialFieldOfView = eventValue;
}

function set_initialFStop (eventValue) // input event received for inputOutput field
{
    initialFStop = eventValue;
}

function set_initialFocusDistance (eventValue) // input event received for inputOutput field
{
    initialFocusDistance = eventValue;
}

function set_key (eventValue) // input event received for inputOutput field
{
    key = eventValue;
}

function set_keyValuePosition (eventValue) // input event received for inputOutput field
{
    keyValuePosition = eventValue;
}

function set_keyValueOrientation (eventValue) // input event received for inputOutput field
{
    keyValueOrientation = eventValue;
}

// TODO consider method set_active for constructed Camera node BooleanSequencer to send isActive

function tracePrint (outputValue)
{
	if (traceEnabled) alwaysPrint (outputValue);
}
function alwaysPrint (outputValue)
{
	// try to ensure outputValue is converted to string despite browser idiosyncracies
    var outputString = outputValue.toString(); // utility function according to spec
    if (outputString == null) outputString = outputValue; // direct cast

    if  (description.length > 0)
         Browser.println ('[CameraShot: ' + description + '] ' + outputString);
    else
         Browser.println ('[CameraShot] ' + outputString);
}

        
]]>
223                      </Script>
224                      <!-- Add any ROUTEs here, going from Script to other nodes within ProtoBody -->
225                 </ProtoBody>
226            </ProtoDeclare>
227            <!-- =============== CameraMovement ============== -->
228            <ProtoDeclare name='CameraMovementappinfo='CameraMovement node defines a single camera movement animation including goalPosition, goalOrientation, goalAimPoint and goalFieldOfView.'>
229                 <ProtoInterface>
230                      <field name='descriptiontype='SFStringaccessType='inputOutput'
                     appinfo='Text description to be displayed for this CameraMovement'/>
231                      <field name='enabledtype='SFBoolvalue='trueaccessType='inputOutput'
                     appinfo='Whether this CameraMovement can be activated'/>
232                      <field name='durationtype='SFFloatvalue='0accessType='inputOutput'
                     appinfo='Duration in seconds for this move'/>
233                      <field name='goalPositiontype='SFVec3fvalue='0 0 10accessType='inputOutput'
                     appinfo='Goal camera position for this move'/>
234                      <field name='goalOrientationtype='SFRotationvalue='0 0 1 0accessType='inputOutput'
                     appinfo='Goal camera rotation for this move'/>
235                      <field name='trackingtype='SFBoolvalue='falseaccessType='inputOutput'
                     appinfo='Whether or not camera direction is tracking towards the aimPoint'/>
236                      <field name='goalAimPointtype='SFVec3fvalue='0 0 0accessType='inputOutput'
                     appinfo='Goal aimPoint for this move, ignored if tracking=false'/>
237                      <field name='goalFieldOfViewtype='SFFloatvalue='0.7854accessType='inputOutput'
                     appinfo='Goal fieldOfView for this move'/>
238                      <field name='goalFStoptype='SFFloatvalue='5.6accessType='inputOutput'
                     appinfo='Focal length divided effective aperture diameter indicating width of focal plane'/>
239                      <field name='goalFocusDistancetype='SFFloatvalue='10accessType='inputOutput'
                     appinfo='Distance to focal plane of sharpest focus'/>
240                      <field name='isActivetype='SFBoolaccessType='outputOnly'
                     appinfo='Mark start/stop with true/false output respectively useful to trigger external animations'/>
241                      <field name='traceEnabledtype='SFBoolvalue='falseaccessType='initializeOnly'
                     appinfo='enable console output to trace script computations and prototype progress'/>
242                 </ProtoInterface>
243                 <ProtoBody>
244                      <!-- First node determines node type of this prototype -->
245                      <!-- Subsequent nodes do not render, but still must be a valid X3D subgraph -->
246                      <!-- Script holds CameraMovement initialization values for query by parent CameraShot, and also permits changing values via events -->
247                      <Script DEF='CameraMovementScriptdirectOutput='truemustEvaluate='true'>
248                           <field name='descriptiontype='SFStringaccessType='inputOutput'
                          appinfo='Text description to be displayed for this CameraMovement'/>
249                           <field name='enabledtype='SFBoolaccessType='inputOutput'
                          appinfo='Whether this CameraMovement can be activated'/>
250                           <field name='durationtype='SFFloataccessType='inputOutput'
                          appinfo='Duration in seconds for this move'/>
251                           <field name='goalPositiontype='SFVec3faccessType='inputOutput'
                          appinfo='Goal camera position for this move'/>
252                           <field name='goalOrientationtype='SFRotationaccessType='inputOutput'
                          appinfo='Goal camera rotation for this move'/>
253                           <field name='trackingtype='SFBoolaccessType='inputOutput'
                          appinfo='Whether or not camera direction is tracking towards the aimPoint'/>
254                           <field name='goalAimPointtype='SFVec3faccessType='inputOutput'
                          appinfo='Goal aimPoint for this move, ignored if tracking=false'/>
255                           <field name='goalFieldOfViewtype='SFFloataccessType='inputOutput'
                          appinfo='Goal fieldOfView for this move'/>
256                           <field name='goalFStoptype='SFFloataccessType='inputOutput'
                          appinfo='Focal length divided effective aperture diameter indicating width of focal plane'/>
257                           <field name='goalFocusDistancetype='SFFloataccessType='inputOutput'
                          appinfo='Distance to focal plane of sharpest focus'/>
258                           <field name='isActivetype='SFBoolaccessType='outputOnly'
                          appinfo='Mark start/stop with true/false output respectively useful to trigger external animations'/>
259                           <field name='traceEnabledtype='SFBoolaccessType='initializeOnly'
                          appinfo='enable console output to trace script computations and prototype progress'/>
260                           <IS>
261                                <connect nodeField='descriptionprotoField='description'/>
262                                <connect nodeField='enabledprotoField='enabled'/>
263                                <connect nodeField='durationprotoField='duration'/>
264                                <connect nodeField='goalPositionprotoField='goalPosition'/>
265                                <connect nodeField='goalOrientationprotoField='goalOrientation'/>
266                                <connect nodeField='trackingprotoField='tracking'/>
267                                <connect nodeField='goalAimPointprotoField='goalAimPoint'/>
268                                <connect nodeField='goalFieldOfViewprotoField='goalFieldOfView'/>
269                                <connect nodeField='goalFStopprotoField='goalFStop'/>
270                                <connect nodeField='goalFocusDistanceprotoField='goalFocusDistance'/>
271                                <connect nodeField='isActiveprotoField='isActive'/>
272                                <connect nodeField='traceEnabledprotoField='traceEnabled'/>
273                           </IS>
  <![CDATA[
          
ecmascript:
function initialize () // CameraMovementScript
{
//  tracePrint ('initialize start...');
    alwaysPrint ('initialize goalPosition=' + goalPosition.toString() + ', goalOrientation=' + goalOrientation.toString() +
                           ', goalAimPoint=' + goalAimPoint.toString() // + ', tracking=' + tracking.toString()
                           );
    if (duration < 0)
    {
       alwaysPrint ('error: negative duration=' + duration + ', reset to 0 and ignored');
       duration = 0;
    }
    else if (duration == 0)
    {
       alwaysPrint ('warning: duration=0, nothing to do!');
    }
    tracePrint ('... initialize complete');
}

function set_goalAimPoint (eventValue) // input event received for inputOutput field
{
    goalAimPoint_changed = eventValue;
    tracePrint ('goalAimPoint=' + goalAimPoint.toString());

    // updated goalOrientation tracking is handled by Camera recomputing the OrientationInterpolator
}

function set_description (eventValue) // input event received for inputOutput field
{
    description = eventValue;
}

function set_enabled (eventValue) // input event received for inputOutput field
{
    enabled = eventValue;
}

function set_duration (eventValue) // input event received for inputOutput field
{
    duration = eventValue;
}

function set_goalPosition (eventValue) // input event received for inputOutput field
{
    goalPosition = eventValue;
}

function set_goalOrientation (eventValue) // input event received for inputOutput field
{
    goalOrientation = eventValue;
}

function set_tracking (eventValue) // input event received for inputOutput field
{
    tracking = eventValue;
}

function set_goalFieldOfView (eventValue) // input event received for inputOutput field
{
    goalFieldOfView = eventValue;
}

function set_goalFStop (eventValue) // input event received for inputOutput field
{
    goalFStop = eventValue;
}

function set_goalFocusDistance (eventValue) // input event received for inputOutput field
{
    goalFocusDistance = eventValue;
}

// TODO consider method set_active for constructed Camera node BooleanSequencer to send isActive

function tracePrint (outputValue)
{
	if (traceEnabled) alwaysPrint (outputValue);
}

function alwaysPrint (outputValue)
{
	// try to ensure outputValue is converted to string despite browser idiosyncracies
    var outputString = outputValue.toString(); // utility function according to spec
    if (outputString == null) outputString = outputValue; // direct cast

    if  (description.length > 0)
         Browser.println ('[CameraMovement: ' + description + '] ' + outputString);
    else
         Browser.println ('[CameraMovement] ' + outputString);
}

        
]]>
275                      </Script>
276                      <!-- Add any ROUTEs here, going from Script to other nodes within ProtoBody -->
277                 </ProtoBody>
278            </ProtoDeclare>
279            <!-- =============== OfflineRender ============== -->
280            <ProtoDeclare name='OfflineRenderappinfo='OfflineRender defines a parameters for offline rendering of Camera animation output to a movie file (or possibly a still shot).'>
281                 <ProtoInterface>
282                      <field name='descriptiontype='SFStringaccessType='inputOutput'
                     appinfo='Text description to be displayed for this OfflineRender'/>
283                      <field name='enabledtype='SFBoolvalue='trueaccessType='inputOutput'
                     appinfo='Whether this OfflineRender can be activated'/>
284                      <field name='frameRatetype='SFFloatvalue='30accessType='inputOutput'
                     appinfo='Frames per second recorded for this rendering'/>
285                      <field name='frameSizetype='SFVec2fvalue='640 480accessType='inputOutput'
                     appinfo='Size of frame in number of pixels width and height'/>
286                      <field name='pixelAspectRatiotype='SFFloatvalue='1.33accessType='inputOutput'
                     appinfo='Relative dimensions of pixel height/width typically 1.33 or 1'/>
287                      <field name='set_startTimetype='SFTimeaccessType='inputOnly'
                     appinfo='Begin render operation'/>
288                      <field name='progresstype='SFFloataccessType='outputOnly'
                     appinfo='Progress performing render operation (0..1)'/>
289                      <field name='renderCompleteTimetype='SFTimeaccessType='outputOnly'
                     appinfo='Render operation complete'/>
290                      <field name='movieFormattype='MFStringvalue='"mpeg"accessType='initializeOnly'
                     appinfo='Format of rendered output movie (mpeg mp4 etc.), use first supported format'/>
291                      <field name='imageFormattype='MFStringvalue='"png"accessType='initializeOnly'
                     appinfo='Format of rendered output images (png jpeg gif tiff etc.) use first supported format'/>
292                      <field name='traceEnabledtype='SFBoolvalue='falseaccessType='initializeOnly'
                     appinfo='enable console output to trace script computations and prototype progress'/>
293                      <!-- TODO non-photorealistic rendering (NPR) parameters -->
294                 </ProtoInterface>
295                 <ProtoBody>
296                      <!-- First node determines node type of this prototype -->
297                      <!-- Subsequent nodes do not render, but still must be a valid X3D subgraph -->
298                      <Script DEF='OfflineRenderScriptmustEvaluate='true'>
299                           <field name='descriptiontype='SFStringaccessType='inputOutput'
                          appinfo='Text description to be displayed for this OfflineRender'/>
300                           <field name='enabledtype='SFBoolaccessType='inputOutput'
                          appinfo='Whether this OfflineRender can be activated'/>
301                           <field name='frameRatetype='SFFloataccessType='inputOutput'
                          appinfo='Frames per second recorded for this rendering'/>
302                           <field name='frameSizetype='SFVec2faccessType='inputOutput'
                          appinfo='Size of frame in number of pixels width and height'/>
303                           <field name='pixelAspectRatiotype='SFFloataccessType='inputOutput'
                          appinfo='Relative dimensions of pixel height/width typically 1.33 or 1'/>
304                           <field name='set_startTimetype='SFTimeaccessType='inputOnly'
                          appinfo='Begin render operation'/>
305                           <field name='progresstype='SFFloataccessType='outputOnly'
                          appinfo='Progress performing render operation (0..1)'/>
306                           <field name='renderCompleteTimetype='SFTimeaccessType='outputOnly'
                          appinfo='Render operation complete'/>
307                           <field name='movieFormattype='MFStringaccessType='initializeOnly'
                          appinfo='Format of rendered output movie (mpeg mp4 etc.)'/>
308                           <field name='imageFormattype='MFStringaccessType='initializeOnly'
                          appinfo='Format of rendered output images (png jpeg gif tiff etc.)'/>
309                           <field name='traceEnabledtype='SFBoolaccessType='initializeOnly'
                          appinfo='enable console output to trace script computations and prototype progress'/>
310                           <IS>
311                                <connect nodeField='descriptionprotoField='description'/>
312                                <connect nodeField='enabledprotoField='enabled'/>
313                                <connect nodeField='frameRateprotoField='frameRate'/>
314                                <connect nodeField='frameSizeprotoField='frameSize'/>
315                                <connect nodeField='pixelAspectRatioprotoField='pixelAspectRatio'/>
316                                <connect nodeField='set_startTimeprotoField='set_startTime'/>
317                                <connect nodeField='progressprotoField='progress'/>
318                                <connect nodeField='renderCompleteTimeprotoField='renderCompleteTime'/>
319                                <connect nodeField='movieFormatprotoField='movieFormat'/>
320                                <connect nodeField='imageFormatprotoField='imageFormat'/>
321                                <connect nodeField='traceEnabledprotoField='traceEnabled'/>
322                           </IS>
  <![CDATA[
          
ecmascript:
function initialize () // OfflineRenderScript
{
//  tracePrint ('initialize start...');

    tracePrint ('... initialize complete');
}

function set_description (eventValue) // input event received for inputOutput field
{
    description = eventValue;
}

function set_enabled (eventValue) // input event received for inputOutput field
{
    enabled = eventValue;
}

function set_frameRate (eventValue) // input event received for inputOutput field
{
    frameRate = eventValue;
}

function set_frameSize (eventValue) // input event received for inputOutput field
{
    frameSize = eventValue;
}

function set_pixelAspectRatio (eventValue) // input event received for inputOutput field
{
    pixelAspectRatio = eventValue;
}

function set_startTime (eventValue) // input event received for inputOnly field
{
   // do something with input eventValue;
}

function tracePrint (outputValue)
{
	if (traceEnabled) alwaysPrint (outputValue);
}

function alwaysPrint (outputValue)
{
	// try to ensure outputValue is converted to string despite browser idiosyncracies
    var outputString = outputValue.toString(); // utility function according to spec
    if (outputString == null) outputString = outputValue; // direct cast

    if  (description.length > 0)
         Browser.println ('[OfflineRender: ' + description + '] ' + outputString);
    else
         Browser.println ('[OfflineRender] ' + outputString);
}

        
]]>
324                      </Script>
325                      <!-- Add any ROUTEs here, going from Script to other nodes within ProtoBody -->
326                 </ProtoBody>
327            </ProtoDeclare>
328            <!-- =============== Launch Prototype Example ============== -->
329            <Background skyColor='0.282353 0.380392 0.470588'/>
330            <Anchor description='launch CameraExample scene'   url=' "CameraExamples.x3d" "https://www.web3d.org/x3d/content/examples/Basic/development/CameraExamples.x3d" "CameraExamples.wrl" "https://www.web3d.org/x3d/content/examples/Basic/development/CameraExamples.wrl" '>
331                 <Transform>
332                      <Shape>
333                           <Text string='"CameraPrototypes.x3d" "defines multiple prototype nodes" "" "Click on this text to see" "CameraExamples.x3d scene"'>
334                                <FontStyle justify='"MIDDLE" "MIDDLE"'/>
335                           </Text>
336                           <Appearance>
337                                <Material diffuseColor='1 1 0.2'/>
338                           </Appearance>
339                      </Shape>
340                 </Transform>
341            </Anchor>
342       </Scene>
343  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: CameraDirectionalLight, CameraMovementScript, CameraNavInfo, CameraOrientationInterpolator, CameraPositionInterpolator, CameraScript, CameraShotScript, CameraViewpoint, OfflineRenderScript

Index for Viewpoint nodes: Viewpoint_1, CameraViewpoint

Index for ProtoDeclare definitions: Camera, CameraMovement, CameraShot, OfflineRender
-->
X3D Tooltips element index: Anchor, Appearance, Background, connect, DirectionalLight, field, FontStyle, head, IS, Material, meta, NavigationInfo, OrientationInterpolator, PositionInterpolator, ProtoBody, ProtoDeclare, ProtoInterface, ROUTE, Scene, Script, Shape, Text, Transform, Viewpoint, WorldInfo, X3D, accessType and type, XML data types, field types

Event Graph ROUTE Table entries with 7 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.

CameraMovementScript
Script
No ROUTE connection found for output events from this node.
This Script has no direct access to other nodes. 

CameraScript
Script
position
SFVec3f

ROUTE
event to
(1)
CameraViewpoint
Viewpoint
position
SFVec3f
CameraScript
Script
orientation
SFRotation

ROUTE
event to
(1)
CameraViewpoint
Viewpoint
orientation
SFRotation
CameraScript
Script
isActive
SFBool

ROUTE
event to
(1)
CameraViewpoint
Viewpoint
set_bind
SFBool
CameraScript
Script
isActive
SFBool

ROUTE
event to
(1)
CameraNavInfo
NavigationInfo
set_bind
SFBool
CameraScript
Script
isActive
SFBool

ROUTE
event to
(1)
CameraDirectionalLight
DirectionalLight
on
SFBool

CameraShotScript
Script
No ROUTE connection found for output events from this node.
Contains MFNode field with direct access to another node.
This Script has no direct access to other nodes. 

OfflineRenderScript
Script
No ROUTE connection found for output events from this node.
This Script has no direct access to other nodes. 


Anchor
description='launch CameraExample scene' 
User-interaction hint for this node. 
Additional guidance on X3D animation can be found in the 10-Step Animation Design Process and Event Tracing hint sheets. Have fun with X3D! 😀

-->
<!-- Online at
https://www.web3d.org/x3d/content/examples/Basic/development/CameraPrototypesIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/development/CameraPrototypes.x3d -->

<!-- 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)
    <ProtoDeclare name='ProtoName'> <field name='fieldName'/> </ProtoDeclare> -->

to top <!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->