@prefix :        <https://www.web3d.org/x3d/content/examples/Basic/Followers/FollowerPrototypeDeclarations.ttl#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema:  <http://schema.org/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
@prefix x3d:     <https://www.web3d.org/specifications/x3d-4.0.xsd#> .
@prefix x3do:    <https://www.web3d.org/specifications/X3dOntology4.0#> .

:X3D a owl:NamedIndividual, x3do:X3D ;
  x3do:hasHead :head ;
  x3do:hasScene :Scene ;
  x3do:profile 'Immersive' ;
  x3do:version '3.2' ;
  x3do:noNamespaceSchemaLocation 'https://www.web3d.org/specifications/x3d-3.2.xsd' .
:head a owl:NamedIndividual, x3do:head ;
  x3do:hasParent :X3D ;
  x3do:hasMeta :meta_1_1, :meta_1_2, :meta_1_3, :meta_1_4, :meta_1_5, :meta_1_6, :meta_1_7, :meta_1_8, :meta_1_9, :meta_1_10, :meta_1_11, :meta_1_12, :meta_1_13, :meta_1_14, :meta_1_15, :meta_1_16, :meta_1_17, :meta_1_18, :meta_1_19, :meta_1_20, :meta_1_21, :meta_1_22, :meta_1_23 .
:meta_1_1 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'FollowerPrototypeDeclarations.x3d' ;
  x3do:name 'title' .
:meta_1_2 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Original implementation pattern as prototype declarations for Follower (Chaser and Damper) nodes, useful for browser developers.' ;
  x3do:name 'description' .
:meta_1_3 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Herbert Stocker' ;
  x3do:name 'creator' .
:meta_1_4 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Don Brutzman' ;
  x3do:name 'translator' .
:meta_1_5 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '18 April 2006' ;
  x3do:name 'created' .
:meta_1_6 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '2 December 2011' ;
  x3do:name 'translated' .
:meta_1_7 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '2 January 2025' ;
  x3do:name 'modified' .
:meta_1_8 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'This scene was used for X3D development and is no longer correct.' ;
  x3do:name 'warning' .
:meta_1_9 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'X3D Architecture, clause 39 Followers component' ;
  x3do:name 'specificationSection' .
:meta_1_10 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'https://www.web3d.org/specifications/X3Dv4/ISO-IEC19775-1v4-IS/Part01/components/followers.html' ;
  x3do:name 'specificationUrl' .
:meta_1_11 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'FollowerExternalPrototypeDeclarations.x3d' ;
  x3do:name 'reference' .
:meta_1_12 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'originals/Chasers.wrl' ;
  x3do:name 'reference' .
:meta_1_13 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'originals/Dampers.wrl' ;
  x3do:name 'reference' .
:meta_1_14 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Stocker_06_Followers.pdf' ;
  x3do:name 'reference' .
:meta_1_15 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'http://www.hersto.com/Publications/Followers' ;
  x3do:name 'reference' .
:meta_1_16 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'X3D version 3.0, 3.1' ;
  x3do:name 'requires' .
:meta_1_17 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'X3D Follower Chaser Damper' ;
  x3do:name 'subject' .
:meta_1_18 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'https://www.web3d.org/x3d/specifications/ISO-IEC-19775-1.2-X3D-AbstractSpecification/Part01/components/followers.html' ;
  x3do:name 'reference' .
:meta_1_19 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html' ;
  x3do:name 'reference' .
:meta_1_20 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'https://www.web3d.org/x3d/content/examples/Basic/Followers/FollowerPrototypeDeclarations.x3d' ;
  x3do:name 'identifier' .
:meta_1_21 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html' ;
  x3do:name 'generator' .
:meta_1_22 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit' ;
  x3do:name 'generator' .
:meta_1_23 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '../../license.html' ;
  x3do:name 'license' .
:meta dcterms:title "FollowerPrototypeDeclarations.x3d" .
:meta dcterms:description "Original implementation pattern as prototype declarations for Follower (Chaser and Damper) nodes, useful for browser developers." .
:meta dcterms:creator "Herbert Stocker" .
:meta dcterms:translator "Don Brutzman" .
:meta dcterms:created "18 April 2006" .
:meta dcterms:translated "2 December 2011" .
:meta dcterms:modified "2 January 2025" .
:meta dcterms:warning "This scene was used for X3D development and is no longer correct." .
:meta dcterms:reference "FollowerExternalPrototypeDeclarations.x3d" .
:meta dcterms:reference "originals/Chasers.wrl" .
:meta dcterms:reference "originals/Dampers.wrl" .
:meta dcterms:reference "Stocker_06_Followers.pdf" .
:meta dcterms:reference "http://www.hersto.com/Publications/Followers" .
:meta dcterms:requires "X3D version 3.0, 3.1" .
:meta dcterms:subject "X3D Follower Chaser Damper" .
:meta dcterms:reference "https://www.web3d.org/x3d/specifications/ISO-IEC-19775-1.2-X3D-AbstractSpecification/Part01/components/followers.html" .
:meta dcterms:reference "https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html" .
:meta dcterms:identifier "https://www.web3d.org/x3d/content/examples/Basic/Followers/FollowerPrototypeDeclarations.x3d" .
:meta dcterms:generator "Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html" .
:meta dcterms:generator "X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit" .
:meta dcterms:license "../../license.html" .
:Scene a owl:NamedIndividual, x3do:Scene ;
  x3do:hasParent :X3D ;
  x3do:hasChildren :WorldInfo_2_1 ;
  x3do:hasProtoDeclare :ProtoDeclare_2_2, :ProtoDeclare_2_3, :ProtoDeclare_2_4, :ProtoDeclare_2_5, :ProtoDeclare_2_6 .
:WorldInfo_2_1 a owl:NamedIndividual, x3do:WorldInfo ;
  x3do:hasParent :Scene ;
  x3do:info '"The ExternProto nodes found in this file implement principles described in the paper" "Linear Filters - Animating Objects in a Flexible and Pleasing Way" "They have been proposed and added to the X3D standard in 2006." "Webpage: http://www.hersto.net/Followers" "" "Please use the code in this file in any content or application you like" "or modify it in any way." "" "The code here works, however things like detecting when a transition has ended" "and when the node can stop calculating and updating the output or secondary fields" "like set_value or initial_destination are not yet implemented." "Nevertheless, set_destination and value_changed do work."' ;
  x3do:title 'Damper nodes' .
:ProtoDeclare_2_2 a owl:NamedIndividual, x3do:ProtoDeclare ;
  x3do:hasParent :Scene ;
  x3do:hasProtoInterface :ProtoInterface_2_2_1 ;
  x3do:hasProtoBody :ProtoBody_2_2_2 ;
  x3do:name 'PositionChaser' .
:ProtoInterface_2_2_1 a owl:NamedIndividual, x3do:ProtoInterface ;
  x3do:hasParent :ProtoDeclare_2_2 ;
  x3do:hasField :field_2_2_1_1, :field_2_2_1_2, :field_2_2_1_3, :field_2_2_1_4, :field_2_2_1_5, :field_2_2_1_6, :field_2_2_1_7, :field_2_2_1_8 .
:field_2_2_1_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_2_1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'value_changed' ;
  x3do:type 'SFVec3f' .
:field_2_2_1_2 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_2_1 ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_value' ;
  x3do:type 'SFVec3f' .
:field_2_2_1_3 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_2_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'credits' ;
  x3do:type 'MFString' ;
  x3do:value '"Initial idea and copyright by Herbert Stocker http://www.hersto.net"' .
:field_2_2_1_4 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_2_1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'isActive' ;
  x3do:type 'SFBool' .
:field_2_2_1_5 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_2_1 ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_destination' ;
  x3do:type 'SFVec3f' .
:field_2_2_1_6 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_2_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'duration' ;
  x3do:type 'SFTime' ;
  x3do:value '1.0' .
:field_2_2_1_7 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_2_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_destination' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:field_2_2_1_8 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_2_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_value' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:ProtoBody_2_2_2 a owl:NamedIndividual, x3do:ProtoBody ;
  x3do:hasParent :ProtoDeclare_2_2 ;
  x3do:hasChildren :ScreenPositionDamper_PositionChaser, :Tmer_PositionChaser ;
  x3do:hasROUTE :ROUTE_2_2_2_3 .
:ScreenPositionDamper_PositionChaser a owl:NamedIndividual, x3do:Script ;
  x3do:hasParent :ProtoBody_2_2_2 ;
  x3do:hasField :field_2_2_2_1_1, :field_2_2_2_1_2, :field_2_2_2_1_3, :field_2_2_2_1_4, :field_2_2_2_1_5, :field_2_2_2_1_6, :field_2_2_2_1_7, :field_2_2_2_1_8, :field_2_2_2_1_9, :field_2_2_2_1_10, :field_2_2_2_1_11, :field_2_2_2_1_12, :field_2_2_2_1_13, :field_2_2_2_1_14, :field_2_2_2_1_15 ;
  x3do:hasIS :IS_2_2_2_1_16 ;
  x3do:DEF 'ScreenPositionDamper_PositionChaser' ;
  x3do:sourceCode """
ecmascript:

function initialize()
{
    CheckInit();
}

function CheckInit()
{
    if(!bInitialized)
    {
        bInitialized= true;  // Init() may call other functions that call CheckInit(). In that case it's better the flag is already set, otherwise an endless loop would occur.
        Init();
    }
}

function Init()
{
    destination= initial_destination;

    Buffer.length= cNumSupports;

    Buffer[0]= initial_destination;
    for(var C= 1; C<Buffer.length; C++ )
        Buffer[C]= initial_value;

    previousValue= initial_value;

    cStepTime= duration / cNumSupports;
}

function set_destination(Dest, Now)
{
    CheckInit();

    destination= Dest;
    // Somehow we assign to Buffer[-1] and wait untill this gets shifted into the real buffer.
    // Would we assign to Buffer[0] instead, we'd have no delay, but this would create a jump in the
    // output because Buffer[0] is associated with a value in the past.

    UpdateBuffer(Now);
}

function Tick(Now)
{
    CheckInit();

    if(!BufferEndTime)
    {
        BufferEndTime= Now; // first event we received, so we are in the initialization phase.

        value_changed= initial_value;
        return;
    }

    var Frac= UpdateBuffer(Now);
    // Frac is a value in   0 <= Frac < 1.

    // Now we can calculate the output.
    // This means we calculate the delta between each entry in Buffer and its previous
    // entries, calculate the step response of each such step and add it to form the output.

    // The oldest vaule Buffer[Buffer.length - 1] needs some extra thought, because it has
    // no previous value. More exactly, we haven't stored a previous value anymore.
    // However, the step response of that missing previous value has already reached its
    // destination, so we can - would we have that previous value - use this as a start point
    // for adding the step responses.
    // Actually UpdateBuffer(.) maintains this value in

    var Output= previousValue;

    var DeltaIn= Buffer[Buffer.length - 1].subtract(previousValue);

    var DeltaOut= DeltaIn.multiply(StepResponse((Buffer.length - 1 + Frac) * cStepTime));

    Output= Output.add(DeltaOut);

    for(var C= Buffer.length - 2; C>=0; C-- )
    {
        var DeltaIn= Buffer[C].subtract(Buffer[C + 1]);

        var DeltaOut= DeltaIn.multiply(StepResponse((C + Frac) * cStepTime));

        Output= Output.add(DeltaOut);
    }
    if(Output != value_changed)
        value_changed= Output;
}

function UpdateBuffer(Now)
{
    var Frac= (Now - BufferEndTime) / cStepTime;
    // is normally < 1. When it has grown to be larger than 1, we have to shift the array because the step response
    // of the oldest entry has already reached its destination, and it's time for a newer entry.
    // has already reached it
    // In the case of a very low frame rate, or a very short cStepTime we may need to shift by more than one entry.

    if(Frac >= 1)
    {
        var NumToShift= Math.floor(Frac);
        Frac-= NumToShift;

        if(NumToShift < Buffer.length)
        {   // normal case.

            previousValue= Buffer[Buffer.length - NumToShift];

            for(var C= Buffer.length - 1; C>=NumToShift; C-- )
                Buffer[C]= Buffer[C - NumToShift];

            for(var C= 0; C<NumToShift; C++ )
            {
                // Hmm, we have a destination value, but don't know how it has
                // reached the current state.
                // Therefore we do a linear interpolation from the latest value in the buffer to destination.

                var Alpha= C / NumToShift;

                Buffer[C]= Buffer[NumToShift].multiply(Alpha).add(destination.multiply((1 - Alpha)));
            }
        }else
        {
            // degenerated case:
            //
            // We have a _VERY_ low frame rate...
            // we can only guess how we should fill the array.
            // Maybe we could write part of a linear interpolation
            // from Buffer[0] to destination, that goes from BufferEndTime to Now
            // (possibly only the end of the interpolation is to be written),
            // but if we rech here we are in a very degenerate case...
            // Thus we just write destination to the buffer.

            previousValue= NumToShift == Buffer.length? Buffer[0] : destination;

            for(var C= 0; C<Buffer.length; C++ )
                Buffer[C]= destination;
        }

        BufferEndTime+= NumToShift * cStepTime;
    }
    return Frac;
}

function StepResponse(t)
{
    if(t < 0)
        return 0;

    if(t > duration)
        return 1;

    // When optimizing for speed, the above two if(.) cases can be omitted,
    // as this funciton will not be called for values outside of 0..duration.

    return StepResponseCore(t / duration);
}

// This function defines the shape of how the output responds to the input.
// It must accept values for T in the range 0 <= T <= 1.
// In order to create a smooth animation, it should return 0 for T == 0,
// 1 for T == 1 and be sufficient smooth in the range 0 <= T <= 1.

// It should be optimized for speed, in order for high performance. It's
// executed Buffer.length + 1 times each simulation tick.

function StepResponseCore(T)
{
    return .5 - .5 * Math.cos(T * Math.PI);
}

// The following functions are not used. They provide other responses (for fun).
function StepResponseCoreF(T)
{
    var cTau= .3;
    var cFrequency= 2.5;
    return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (1 - T);
//      return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (1 - T) * (1 - T);
//      return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (.5 + .5 * Math.cos(T * Math.PI));
//      return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (.5 + .5 * Math.cos(T * Math.PI))* (.5 + .5 * Math.cos(T * Math.PI));
}


function StepResponseCoreE(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

    var cFrequency= 2.5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.sin(Math.sqrt(1 - T) * Math.PI/2);

    return A * .8 + B * .2;
}


function StepResponseCoreD(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

    var cFrequency= 2.5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.sin((1 - T) * Math.PI/2);

    return A * .8 + B * .2;
}

function StepResponseCoreC(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

    var cTau= .3;
    var cFrequency= 5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (1 - T);

    return A * .8 + B * .2;
}

function StepResponseCoreB(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

    var cTau= .3;
    var cFrequency= 5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) /** Math.exp(-T / cTau)*/ * (1 - T);

    return A * .8 + B * .2;
}
function StepResponseCoreA(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

    var cTau= .3;
    var cFrequency= 5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) /** Math.exp(-T / cTau)*/ * (1 - T);

    var Alpha= .2 * T;
    return A * (1 - Alpha) + B * Alpha;
}
""" .
:field_2_2_2_1_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'Tick' ;
  x3do:type 'SFTime' .
:field_2_2_2_1_2 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_value' ;
  x3do:type 'SFVec3f' .
:field_2_2_2_1_3 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'duration' ;
  x3do:type 'SFTime' .
:field_2_2_2_1_4 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'Buffer' ;
  x3do:type 'MFVec3f' .
:field_2_2_2_1_5 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'bInitialized' ;
  x3do:type 'SFBool' ;
  x3do:value false .
:field_2_2_2_1_6 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'BufferEndTime' ;
  x3do:type 'SFTime' ;
  x3do:value '0.0' .
:field_2_2_2_1_7 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'cNumSupports' ;
  x3do:type 'SFInt32' ;
  x3do:value 10 .
:field_2_2_2_1_8 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_destination' ;
  x3do:type 'SFVec3f' .
:field_2_2_2_1_9 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'value_changed' ;
  x3do:type 'SFVec3f' .
:field_2_2_2_1_10 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'cStepTime' ;
  x3do:type 'SFTime' ;
  x3do:value '0.0' .
:field_2_2_2_1_11 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'previousValue' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:field_2_2_2_1_12 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_destination' ;
  x3do:type 'SFVec3f' .
:field_2_2_2_1_13 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'destination' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:field_2_2_2_1_14 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'isActive' ;
  x3do:type 'SFBool' .
:field_2_2_2_1_15 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_value' ;
  x3do:type 'SFVec3f' .
:IS_2_2_2_1_16 a owl:NamedIndividual, x3do:IS ;
  x3do:hasParent :ScreenPositionDamper_PositionChaser ;
  x3do:hasConnect :connect_2_2_2_1_16_1, :connect_2_2_2_1_16_2, :connect_2_2_2_1_16_3, :connect_2_2_2_1_16_4, :connect_2_2_2_1_16_5, :connect_2_2_2_1_16_6, :connect_2_2_2_1_16_7 .
:connect_2_2_2_1_16_1 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_2_2_1_16 ;
  x3do:nodeField 'set_value' ;
  x3do:protoField 'set_value' .
:connect_2_2_2_1_16_2 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_2_2_1_16 ;
  x3do:nodeField 'duration' ;
  x3do:protoField 'duration' .
:connect_2_2_2_1_16_3 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_2_2_1_16 ;
  x3do:nodeField 'set_destination' ;
  x3do:protoField 'set_destination' .
:connect_2_2_2_1_16_4 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_2_2_1_16 ;
  x3do:nodeField 'value_changed' ;
  x3do:protoField 'value_changed' .
:connect_2_2_2_1_16_5 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_2_2_1_16 ;
  x3do:nodeField 'initial_destination' ;
  x3do:protoField 'initial_destination' .
:connect_2_2_2_1_16_6 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_2_2_1_16 ;
  x3do:nodeField 'isActive' ;
  x3do:protoField 'isActive' .
:connect_2_2_2_1_16_7 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_2_2_1_16 ;
  x3do:nodeField 'initial_value' ;
  x3do:protoField 'initial_value' .
:Tmer_PositionChaser a owl:NamedIndividual, x3do:TimeSensor ;
  x3do:hasParent :ProtoBody_2_2_2 ;
  x3do:DEF 'Tmer_PositionChaser' ;
  x3do:loop true .
:ROUTE_2_2_2_3 a owl:NamedIndividual, x3do:ROUTE ;
  x3do:hasParent :ProtoBody_2_2_2 ;
  x3do:fromField 'time' ;
  x3do:fromNode 'Tmer_PositionChaser' ;
  x3do:toField 'Tick' ;
  x3do:toNode 'ScreenPositionDamper_PositionChaser' .
:ProtoDeclare_2_3 a owl:NamedIndividual, x3do:ProtoDeclare ;
  x3do:hasParent :Scene ;
  x3do:hasProtoInterface :ProtoInterface_2_3_1 ;
  x3do:hasProtoBody :ProtoBody_2_3_2 ;
  x3do:name 'OrientationChaser' .
:ProtoInterface_2_3_1 a owl:NamedIndividual, x3do:ProtoInterface ;
  x3do:hasParent :ProtoDeclare_2_3 ;
  x3do:hasField :field_2_3_1_1, :field_2_3_1_2, :field_2_3_1_3, :field_2_3_1_4, :field_2_3_1_5, :field_2_3_1_6, :field_2_3_1_7, :field_2_3_1_8 .
:field_2_3_1_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_3_1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'value_changed' ;
  x3do:type 'SFRotation' .
:field_2_3_1_2 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_3_1 ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_value' ;
  x3do:type 'SFRotation' .
:field_2_3_1_3 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_3_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'credits' ;
  x3do:type 'MFString' ;
  x3do:value '"Initial idea and copyright by Herbert Stocker http://www.hersto.net/"' .
:field_2_3_1_4 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_3_1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'isActive' ;
  x3do:type 'SFBool' .
:field_2_3_1_5 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_3_1 ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_destination' ;
  x3do:type 'SFRotation' .
:field_2_3_1_6 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_3_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'duration' ;
  x3do:type 'SFTime' ;
  x3do:value '1.0' .
:field_2_3_1_7 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_3_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_destination' ;
  x3do:type 'SFRotation' ;
  x3do:value ( 0.0 0.0 1.0 0.0 ) .
:field_2_3_1_8 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_3_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_value' ;
  x3do:type 'SFRotation' ;
  x3do:value ( 0.0 0.0 1.0 0.0 ) .
:ProtoBody_2_3_2 a owl:NamedIndividual, x3do:ProtoBody ;
  x3do:hasParent :ProtoDeclare_2_3 ;
  x3do:hasChildren :ScreenPositionDamper_OrientationChaser, :Tmer_OrientationChaser ;
  x3do:hasROUTE :ROUTE_2_3_2_3 .
:ScreenPositionDamper_OrientationChaser a owl:NamedIndividual, x3do:Script ;
  x3do:hasParent :ProtoBody_2_3_2 ;
  x3do:hasField :field_2_3_2_1_1, :field_2_3_2_1_2, :field_2_3_2_1_3, :field_2_3_2_1_4, :field_2_3_2_1_5, :field_2_3_2_1_6, :field_2_3_2_1_7, :field_2_3_2_1_8, :field_2_3_2_1_9, :field_2_3_2_1_10, :field_2_3_2_1_11, :field_2_3_2_1_12, :field_2_3_2_1_13, :field_2_3_2_1_14, :field_2_3_2_1_15 ;
  x3do:hasIS :IS_2_3_2_1_16 ;
  x3do:DEF 'ScreenPositionDamper_OrientationChaser' ;
  x3do:sourceCode """
ecmascript:

function initialize()
{
    CheckInit();
}

function CheckInit()
{
    if(!bInitialized)
    {
        bInitialized= true;  // Init() may call other functions that call CheckInit(). In that case it's better the flag is already set, otherwise an endless loop would occur.
        Init();
    }
}

function Init()
{
    destination= initial_destination;

    Buffer.length= cNumSupports;

    Buffer[0]= initial_destination;
    for(var C= 1; C<Buffer.length; C++ )
        Buffer[C]= initial_value;

    previousValue= initial_value;

    cStepTime= duration / cNumSupports;
}

function set_destination(Dest, Now)
{
    CheckInit();

    destination= Dest;
    // Somehow we assign to Buffer[-1] and wait untill this gets shifted into the real buffer.
    // Would we assign to Buffer[0] instead, we'd have no delay, but this would create a jump in the
    // output because Buffer[0] is associated with a value in the past.

    UpdateBuffer(Now);
}

function Tick(Now)
{
    CheckInit();

    if(!BufferEndTime)
    {
        BufferEndTime= Now; // first event we received, so we are in the initialization phase.

        value_changed= initial_value;
        return;
    }

    var Frac= UpdateBuffer(Now);
    // Frac is a value in   0 <= Frac < 1.

    // Now we can calculate the output.
    // This means we calculate the delta between each entry in Buffer and its previous
    // entries, calculate the step response of each such step and add it to form the output.

    // The oldest vaule Buffer[Buffer.length - 1] needs some extra thought, because it has
    // no previous value. More exactly, we haven't stored a previous value anymore.
    // However, the step response of that missing previous value has already reached its
    // destination, so we can - would we have that previous value - use this as a start point
    // for adding the step responses.
    // Actually UpdateBuffer(.) maintains this value in

    var Output= previousValue;

    var DeltaIn= previousValue.inverse().multiply(Buffer[Buffer.length - 1]);

    Output= Output.slerp(Output.multiply(DeltaIn), StepResponse((Buffer.length - 1 + Frac) * cStepTime));

    for(var C= Buffer.length - 2; C>=0; C-- )
    {
        var DeltaIn= Buffer[C + 1].inverse().multiply(Buffer[C]);

        Output= Output.slerp(Output.multiply(DeltaIn), StepResponse((C + Frac) * cStepTime));
    }


    if(Output != value_changed)
        value_changed= Output;
}

function UpdateBuffer(Now)
{
    var Frac= (Now - BufferEndTime) / cStepTime;
    // is normally < 1. When it has grown to be larger than 1, we have to shift the array because the step response
    // of the oldest entry has already reached its destination, and it's time for a newer entry.
    // has already reached it
    // In the case of a very low frame rate, or a very short cStepTime we may need to shift by more than one entry.

    if(Frac >= 1)
    {
        var NumToShift= Math.floor(Frac);
        Frac-= NumToShift;

        if(NumToShift < Buffer.length)
        {   // normal case.

            previousValue= Buffer[Buffer.length - NumToShift];

            for(var C= Buffer.length - 1; C>=NumToShift; C-- )
                Buffer[C]= Buffer[C - NumToShift];

            for(var C= 0; C<NumToShift; C++ )
            {
                // Hmm, we have a destination value, but don't know how it has
                // reached the current state.
                // Therefore we do a linear interpolation from the latest value in the buffer to destination.

                Buffer[C]= destination.slerp(Buffer[NumToShift], C / NumToShift);
            }
        }else
        {
            // degenerated case:
            //
            // We have a _VERY_ low frame rate...
            // we can only guess how we should fill the array.
            // Maybe we could write part of a linear interpolation
            // from Buffer[0] to destination, that goes from BufferEndTime to Now
            // (possibly only the end of the interpolation is to be written),
            // but if we rech here we are in a very degenerate case...
            // Thus we just write destination to the buffer.

            previousValue= NumToShift == Buffer.length? Buffer[0] : destination;

            for(var C= 0; C<Buffer.length; C++ )
                Buffer[C]= destination;
        }
        BufferEndTime+= NumToShift * cStepTime;
    }

return Frac;
}

function StepResponse(t)
{
    if(t < 0)
        return 0;

    if(t > duration)
        return 1;

    // When optimizing for speed, the above two if(.) cases can be omitted,
    // as this funciton will not be called for values outside of 0..duration.

     return StepResponseCore(t / duration);
}

// This function defines the shape of how the output responds to the input.
// It must accept values for T in the range 0 <= T <= 1.
// In order to create a smooth animation, it should return 0 for T == 0,
// 1 for T == 1 and be sufficient smooth in the range 0 <= T <= 1.

// It should be optimized for speed, in order for high performance. It's
// executed Buffer.length + 1 times each simulation tick.

function StepResponseCore(T)
{
    return .5 - .5 * Math.cos(T * Math.PI);
}

// The following functions are not used. They provide other responses (for fun).

function StepResponseCoreG(T)
{
    var cTau= .3;
    var cFrequency= 5;
    return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (.5 + .5 * Math.cos(T * Math.PI));
}

function StepResponseCoreF(T)
{
    var cTau= .3;
    var cFrequency= 2.5;
//      return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (1 - T);
//      return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (1 - T) * (1 - T);
//      return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (.5 + .5 * Math.cos(T * Math.PI));
//      return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (.5 + .5 * Math.cos(T * Math.PI))* (.5 + .5 * Math.cos(T * Math.PI));
}

function StepResponseCoreE(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

    var cFrequency= 2.5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.sin(Math.sqrt(1 - T) * Math.PI/2);

    return A * .8 + B * .2;
}

function StepResponseCoreD(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

    var cFrequency= 2.5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.sin((1 - T) * Math.PI/2);

    return A * .8 + B * .2;
}

function StepResponseCoreC(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

    var cTau= .3;
    var cFrequency= 5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (1 - T);

    return A * .8 + B * .2;
}

function StepResponseCoreB(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

    var cTau= .3;
    var cFrequency= 5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) /** Math.exp(-T / cTau)*/ * (1 - T);

    return A * .8 + B * .2;
}

function StepResponseCoreA(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);
    var cTau= .3;
    var cFrequency= 5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) /** Math.exp(-T / cTau)*/ * (1 - T);
    var Alpha= .2 * T;
    return A * (1 - Alpha) + B * Alpha;
}
""" .
:field_2_3_2_1_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'Tick' ;
  x3do:type 'SFTime' .
:field_2_3_2_1_2 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_value' ;
  x3do:type 'SFRotation' .
:field_2_3_2_1_3 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'duration' ;
  x3do:type 'SFTime' .
:field_2_3_2_1_4 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'Buffer' ;
  x3do:type 'MFRotation' .
:field_2_3_2_1_5 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'bInitialized' ;
  x3do:type 'SFBool' ;
  x3do:value false .
:field_2_3_2_1_6 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'BufferEndTime' ;
  x3do:type 'SFTime' ;
  x3do:value '0.0' .
:field_2_3_2_1_7 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'cNumSupports' ;
  x3do:type 'SFInt32' ;
  x3do:value 10 .
:field_2_3_2_1_8 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_destination' ;
  x3do:type 'SFRotation' .
:field_2_3_2_1_9 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'value_changed' ;
  x3do:type 'SFRotation' .
:field_2_3_2_1_10 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'cStepTime' ;
  x3do:type 'SFTime' ;
  x3do:value '0.0' .
:field_2_3_2_1_11 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'previousValue' ;
  x3do:type 'SFRotation' ;
  x3do:value ( 0.0 0.0 1.0 0.0 ) .
:field_2_3_2_1_12 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_destination' ;
  x3do:type 'SFRotation' .
:field_2_3_2_1_13 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'destination' ;
  x3do:type 'SFRotation' ;
  x3do:value ( 0.0 0.0 1.0 0.0 ) .
:field_2_3_2_1_14 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'isActive' ;
  x3do:type 'SFBool' .
:field_2_3_2_1_15 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_value' ;
  x3do:type 'SFRotation' .
:IS_2_3_2_1_16 a owl:NamedIndividual, x3do:IS ;
  x3do:hasParent :ScreenPositionDamper_OrientationChaser ;
  x3do:hasConnect :connect_2_3_2_1_16_1, :connect_2_3_2_1_16_2, :connect_2_3_2_1_16_3, :connect_2_3_2_1_16_4, :connect_2_3_2_1_16_5, :connect_2_3_2_1_16_6, :connect_2_3_2_1_16_7 .
:connect_2_3_2_1_16_1 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_3_2_1_16 ;
  x3do:nodeField 'set_value' ;
  x3do:protoField 'set_value' .
:connect_2_3_2_1_16_2 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_3_2_1_16 ;
  x3do:nodeField 'duration' ;
  x3do:protoField 'duration' .
:connect_2_3_2_1_16_3 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_3_2_1_16 ;
  x3do:nodeField 'set_destination' ;
  x3do:protoField 'set_destination' .
:connect_2_3_2_1_16_4 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_3_2_1_16 ;
  x3do:nodeField 'value_changed' ;
  x3do:protoField 'value_changed' .
:connect_2_3_2_1_16_5 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_3_2_1_16 ;
  x3do:nodeField 'initial_destination' ;
  x3do:protoField 'initial_destination' .
:connect_2_3_2_1_16_6 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_3_2_1_16 ;
  x3do:nodeField 'isActive' ;
  x3do:protoField 'isActive' .
:connect_2_3_2_1_16_7 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_3_2_1_16 ;
  x3do:nodeField 'initial_value' ;
  x3do:protoField 'initial_value' .
:Tmer_OrientationChaser a owl:NamedIndividual, x3do:TimeSensor ;
  x3do:hasParent :ProtoBody_2_3_2 ;
  x3do:DEF 'Tmer_OrientationChaser' ;
  x3do:loop true .
:ROUTE_2_3_2_3 a owl:NamedIndividual, x3do:ROUTE ;
  x3do:hasParent :ProtoBody_2_3_2 ;
  x3do:fromField 'time' ;
  x3do:fromNode 'Tmer_OrientationChaser' ;
  x3do:toField 'Tick' ;
  x3do:toNode 'ScreenPositionDamper_OrientationChaser' .
:ProtoDeclare_2_4 a owl:NamedIndividual, x3do:ProtoDeclare ;
  x3do:hasParent :Scene ;
  x3do:hasProtoInterface :ProtoInterface_2_4_1 ;
  x3do:hasProtoBody :ProtoBody_2_4_2 ;
  x3do:name 'Position2fChaser' .
:ProtoInterface_2_4_1 a owl:NamedIndividual, x3do:ProtoInterface ;
  x3do:hasParent :ProtoDeclare_2_4 ;
  x3do:hasField :field_2_4_1_1, :field_2_4_1_2, :field_2_4_1_3, :field_2_4_1_4, :field_2_4_1_5, :field_2_4_1_6, :field_2_4_1_7, :field_2_4_1_8 .
:field_2_4_1_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_4_1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'value_changed' ;
  x3do:type 'SFVec2f' .
:field_2_4_1_2 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_4_1 ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_value' ;
  x3do:type 'SFVec2f' .
:field_2_4_1_3 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_4_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'credits' ;
  x3do:type 'MFString' ;
  x3do:value '"Initial idea and copyright by Herbert Stocker http://www.hersto.net/"' .
:field_2_4_1_4 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_4_1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'isActive' ;
  x3do:type 'SFBool' .
:field_2_4_1_5 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_4_1 ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_destination' ;
  x3do:type 'SFVec2f' .
:field_2_4_1_6 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_4_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'duration' ;
  x3do:type 'SFTime' ;
  x3do:value '1.0' .
:field_2_4_1_7 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_4_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_destination' ;
  x3do:type 'SFVec2f' ;
  x3do:value ( 0.0 0.0 ) .
:field_2_4_1_8 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_4_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_value' ;
  x3do:type 'SFVec2f' ;
  x3do:value ( 0.0 0.0 ) .
:ProtoBody_2_4_2 a owl:NamedIndividual, x3do:ProtoBody ;
  x3do:hasParent :ProtoDeclare_2_4 ;
  x3do:hasChildren :ScreenPositionDamper_Position2fChaser, :Tmer_Position2fChaser ;
  x3do:hasROUTE :ROUTE_2_4_2_3 .
:ScreenPositionDamper_Position2fChaser a owl:NamedIndividual, x3do:Script ;
  x3do:hasParent :ProtoBody_2_4_2 ;
  x3do:hasField :field_2_4_2_1_1, :field_2_4_2_1_2, :field_2_4_2_1_3, :field_2_4_2_1_4, :field_2_4_2_1_5, :field_2_4_2_1_6, :field_2_4_2_1_7, :field_2_4_2_1_8, :field_2_4_2_1_9, :field_2_4_2_1_10, :field_2_4_2_1_11, :field_2_4_2_1_12, :field_2_4_2_1_13, :field_2_4_2_1_14, :field_2_4_2_1_15 ;
  x3do:hasIS :IS_2_4_2_1_16 ;
  x3do:DEF 'ScreenPositionDamper_Position2fChaser' ;
  x3do:sourceCode """
ecmascript:

function initialize()
{
    CheckInit();
}

function CheckInit()
{
    if(!bInitialized)
    {
        bInitialized= true;  // Init() may call other functions that call CheckInit(). In that case it's better the flag is already set, otherwise an endless loop would occur.
        Init();
    }
}

function Init()
{
    destination= initial_destination;

    Buffer.length= cNumSupports;

    Buffer[0]= initial_destination;
    for(var C= 1; C<Buffer.length; C++ )
        Buffer[C]= initial_value;

    previousValue= initial_value;

    cStepTime= duration / cNumSupports;
}

function set_destination(Dest, Now)
{
    CheckInit();

    destination= Dest;
    // Somehow we assign to Buffer[-1] and wait untill this gets shifted into the real buffer.
    // Would we assign to Buffer[0] instead, we'd have no delay, but this would create a jump in the
    // output because Buffer[0] is associated with a value in the past.

    UpdateBuffer(Now);
}

function Tick(Now)
{
    CheckInit();

    if(!BufferEndTime)
    {
        BufferEndTime= Now; // first event we received, so we are in the initialization phase.

        value_changed= initial_value;
        return;
    }

    var Frac= UpdateBuffer(Now);
    // Frac is a value in   0 <= Frac < 1.

    // Now we can calculate the output.
    // This means we calculate the delta between each entry in Buffer and its previous
    // entries, calculate the step response of each such step and add it to form the output.

    // The oldest vaule Buffer[Buffer.length - 1] needs some extra thought, because it has
    // no previous value. More exactly, we haven't stored a previous value anymore.
    // However, the step response of that missing previous value has already reached its
    // destination, so we can - would we have that previous value - use this as a start point
    // for adding the step responses.
    // Actually UpdateBuffer(.) maintains this value in

    var Output= previousValue;

    var DeltaIn= Buffer[Buffer.length - 1].subtract(previousValue);

    var DeltaOut= DeltaIn.multiply(StepResponse((Buffer.length - 1 + Frac) * cStepTime));

    Output= Output.add(DeltaOut);

    for(var C= Buffer.length - 2; C>=0; C-- )
    {
        var DeltaIn= Buffer[C].subtract(Buffer[C + 1]);

        var DeltaOut= DeltaIn.multiply(StepResponse((C + Frac) * cStepTime));

        Output= Output.add(DeltaOut);
    }


    if(Output != value_changed)
        value_changed= Output;
}

function UpdateBuffer(Now)
{
    var Frac= (Now - BufferEndTime) / cStepTime;
    // is normally < 1. When it has grown to be larger than 1, we have to shift the array because the step response
    // of the oldest entry has already reached its destination, and it's time for a newer entry.
    // has already reached it
    // In the case of a very low frame rate, or a very short cStepTime we may need to shift by more than one entry.

    if(Frac >= 1)
    {
        var NumToShift= Math.floor(Frac);
        Frac-= NumToShift;

        if(NumToShift < Buffer.length)
        {   // normal case.

            previousValue= Buffer[Buffer.length - NumToShift];

            for(var C= Buffer.length - 1; C>=NumToShift; C-- )
                Buffer[C]= Buffer[C - NumToShift];

            for(var C= 0; C<NumToShift; C++ )
            {
                // Hmm, we have a destination value, but don't know how it has
                // reached the current state.
                // Therefore we do a linear interpolation from the latest value in the buffer to destination.

                var Alpha= C / NumToShift;

                Buffer[C]= Buffer[NumToShift].multiply(Alpha).add(destination.multiply((1 - Alpha)));
            }
        }else
        {
            // degenerated case:
            //
            // We have a _VERY_ low frame rate...
            // we can only guess how we should fill the array.
            // Maybe we could write part of a linear interpolation
            // from Buffer[0] to destination, that goes from BufferEndTime to Now
            // (possibly only the end of the interpolation is to be written),
            // but if we rech here we are in a very degenerate case...
            // Thus we just write destination to the buffer.

            previousValue= NumToShift == Buffer.length? Buffer[0] : destination;

            for(var C= 0; C<Buffer.length; C++ )
                Buffer[C]= destination;
        }

        BufferEndTime+= NumToShift * cStepTime;
    }

return Frac;
}



function StepResponse(t)
{
    if(t < 0)
return 0;

    if(t > duration)
return 1;

    // When optimizing for speed, the above two if(.) cases can be omitted,
    // as this funciton will not be called for values outside of 0..duration.

return StepResponseCore(t / duration);
}


// This function defines the shape of how the output responds to the input.
// It must accept values for T in the range 0 <= T <= 1.
// In order to create a smooth animation, it should return 0 for T == 0,
// 1 for T == 1 and be sufficient smooth in the range 0 <= T <= 1.

// It should be optimized for speed, in order for high performance. It's
// executed Buffer.length + 1 times each simulation tick.
function StepResponseCore(T)
{
return .5 - .5 * Math.cos(T * Math.PI);
}


// The following functions are not used. They provide other responses (for fun).
function StepResponseCoreF(T)
{
    var cTau= .3;
    var cFrequency= 2.5;
return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (1 - T);
//      return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (1 - T) * (1 - T);
//      return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (.5 + .5 * Math.cos(T * Math.PI));
//      return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (.5 + .5 * Math.cos(T * Math.PI))* (.5 + .5 * Math.cos(T * Math.PI));
}

function StepResponseCoreE(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

  var cFrequency= 2.5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.sin(Math.sqrt(1 - T) * Math.PI/2);

return A * .8 + B * .2;
}

function StepResponseCoreD(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

  var cFrequency= 2.5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.sin((1 - T) * Math.PI/2);

return A * .8 + B * .2;
}

function StepResponseCoreC(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

  var cTau= .3;
  var cFrequency= 5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (1 - T);

return A * .8 + B * .2;
}

function StepResponseCoreB(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

  var cTau= .3;
  var cFrequency= 5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) /** Math.exp(-T / cTau)*/ * (1 - T);

return A * .8 + B * .2;
}

function StepResponseCoreA(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

  var cTau= .3;
  var cFrequency= 5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) /** Math.exp(-T / cTau)*/ * (1 - T);

    var Alpha= .2 * T;
return A * (1 - Alpha) + B * Alpha;
}
""" .
:field_2_4_2_1_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'Tick' ;
  x3do:type 'SFTime' .
:field_2_4_2_1_2 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_value' ;
  x3do:type 'SFVec2f' .
:field_2_4_2_1_3 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'duration' ;
  x3do:type 'SFTime' .
:field_2_4_2_1_4 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'Buffer' ;
  x3do:type 'MFVec2f' .
:field_2_4_2_1_5 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'bInitialized' ;
  x3do:type 'SFBool' ;
  x3do:value false .
:field_2_4_2_1_6 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'BufferEndTime' ;
  x3do:type 'SFTime' ;
  x3do:value '0.0' .
:field_2_4_2_1_7 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'cNumSupports' ;
  x3do:type 'SFInt32' ;
  x3do:value 10 .
:field_2_4_2_1_8 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_destination' ;
  x3do:type 'SFVec2f' .
:field_2_4_2_1_9 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'value_changed' ;
  x3do:type 'SFVec2f' .
:field_2_4_2_1_10 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'cStepTime' ;
  x3do:type 'SFTime' ;
  x3do:value '0.0' .
:field_2_4_2_1_11 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'previousValue' ;
  x3do:type 'SFVec2f' ;
  x3do:value ( 0.0 0.0 ) .
:field_2_4_2_1_12 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_destination' ;
  x3do:type 'SFVec2f' .
:field_2_4_2_1_13 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'destination' ;
  x3do:type 'SFVec2f' ;
  x3do:value ( 0.0 0.0 ) .
:field_2_4_2_1_14 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'isActive' ;
  x3do:type 'SFBool' .
:field_2_4_2_1_15 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_value' ;
  x3do:type 'SFVec2f' .
:IS_2_4_2_1_16 a owl:NamedIndividual, x3do:IS ;
  x3do:hasParent :ScreenPositionDamper_Position2fChaser ;
  x3do:hasConnect :connect_2_4_2_1_16_1, :connect_2_4_2_1_16_2, :connect_2_4_2_1_16_3, :connect_2_4_2_1_16_4, :connect_2_4_2_1_16_5, :connect_2_4_2_1_16_6, :connect_2_4_2_1_16_7 .
:connect_2_4_2_1_16_1 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_4_2_1_16 ;
  x3do:nodeField 'set_value' ;
  x3do:protoField 'set_value' .
:connect_2_4_2_1_16_2 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_4_2_1_16 ;
  x3do:nodeField 'duration' ;
  x3do:protoField 'duration' .
:connect_2_4_2_1_16_3 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_4_2_1_16 ;
  x3do:nodeField 'set_destination' ;
  x3do:protoField 'set_destination' .
:connect_2_4_2_1_16_4 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_4_2_1_16 ;
  x3do:nodeField 'value_changed' ;
  x3do:protoField 'value_changed' .
:connect_2_4_2_1_16_5 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_4_2_1_16 ;
  x3do:nodeField 'initial_destination' ;
  x3do:protoField 'initial_destination' .
:connect_2_4_2_1_16_6 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_4_2_1_16 ;
  x3do:nodeField 'isActive' ;
  x3do:protoField 'isActive' .
:connect_2_4_2_1_16_7 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_4_2_1_16 ;
  x3do:nodeField 'initial_value' ;
  x3do:protoField 'initial_value' .
:Tmer_Position2fChaser a owl:NamedIndividual, x3do:TimeSensor ;
  x3do:hasParent :ProtoBody_2_4_2 ;
  x3do:DEF 'Tmer_Position2fChaser' ;
  x3do:loop true .
:ROUTE_2_4_2_3 a owl:NamedIndividual, x3do:ROUTE ;
  x3do:hasParent :ProtoBody_2_4_2 ;
  x3do:fromField 'time' ;
  x3do:fromNode 'Tmer_Position2fChaser' ;
  x3do:toField 'Tick' ;
  x3do:toNode 'ScreenPositionDamper_Position2fChaser' .
:ProtoDeclare_2_5 a owl:NamedIndividual, x3do:ProtoDeclare ;
  x3do:hasParent :Scene ;
  x3do:hasProtoInterface :ProtoInterface_2_5_1 ;
  x3do:hasProtoBody :ProtoBody_2_5_2 ;
  x3do:name 'PlacementChaser' .
:ProtoInterface_2_5_1 a owl:NamedIndividual, x3do:ProtoInterface ;
  x3do:hasParent :ProtoDeclare_2_5 ;
  x3do:hasField :field_2_5_1_1, :field_2_5_1_2, :field_2_5_1_3, :field_2_5_1_4, :field_2_5_1_5, :field_2_5_1_6, :field_2_5_1_7, :field_2_5_1_8, :field_2_5_1_9, :field_2_5_1_10, :field_2_5_1_11, :field_2_5_1_12, :field_2_5_1_13, :field_2_5_1_14 .
:field_2_5_1_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_5_1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'isLoaded' ;
  x3do:type 'SFBool' .
:field_2_5_1_2 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_5_1 ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_valuePos' ;
  x3do:type 'SFVec3f' .
:field_2_5_1_3 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_5_1 ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_valueOri' ;
  x3do:type 'SFRotation' .
:field_2_5_1_4 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_5_1 ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_destinationPos' ;
  x3do:type 'SFVec3f' .
:field_2_5_1_5 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_5_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'credits' ;
  x3do:type 'MFString' ;
  x3do:value '"Initial idea and copyright by Herbert Stocker http://www.hersto.net/"' .
:field_2_5_1_6 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_5_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'duration' ;
  x3do:type 'SFTime' ;
  x3do:value '1.0' .
:field_2_5_1_7 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_5_1 ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_destinationOri' ;
  x3do:type 'SFRotation' .
:field_2_5_1_8 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_5_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_valuePos' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:field_2_5_1_9 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_5_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_destinationPos' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:field_2_5_1_10 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_5_1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'valuePos_changed' ;
  x3do:type 'SFVec3f' .
:field_2_5_1_11 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_5_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_valueOri' ;
  x3do:type 'SFRotation' ;
  x3do:value ( 0.0 0.0 1.0 0.0 ) .
:field_2_5_1_12 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_5_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_destinationOri' ;
  x3do:type 'SFRotation' ;
  x3do:value ( 0.0 0.0 1.0 0.0 ) .
:field_2_5_1_13 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_5_1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'valueOri_changed' ;
  x3do:type 'SFRotation' .
:field_2_5_1_14 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_5_1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'isActive' ;
  x3do:type 'SFBool' .
:ProtoBody_2_5_2 a owl:NamedIndividual, x3do:ProtoBody ;
  x3do:hasParent :ProtoDeclare_2_5 ;
  x3do:hasChildren :ScreenPositionDamper_PlacementChaser, :Tmer_PlacementChaser, :LastNode ;
  x3do:hasROUTE :ROUTE_2_5_2_3 .
:ScreenPositionDamper_PlacementChaser a owl:NamedIndividual, x3do:Script ;
  x3do:hasParent :ProtoBody_2_5_2 ;
  x3do:hasField :field_2_5_2_1_1, :field_2_5_2_1_2, :field_2_5_2_1_3, :field_2_5_2_1_4, :field_2_5_2_1_5, :field_2_5_2_1_6, :field_2_5_2_1_7, :field_2_5_2_1_8, :field_2_5_2_1_9, :field_2_5_2_1_10, :field_2_5_2_1_11, :field_2_5_2_1_12, :field_2_5_2_1_13, :field_2_5_2_1_14, :field_2_5_2_1_15, :field_2_5_2_1_16, :field_2_5_2_1_17, :field_2_5_2_1_18, :field_2_5_2_1_19, :field_2_5_2_1_20, :field_2_5_2_1_21, :field_2_5_2_1_22, :field_2_5_2_1_23 ;
  x3do:hasIS :IS_2_5_2_1_24 ;
  x3do:DEF 'ScreenPositionDamper_PlacementChaser' ;
  x3do:sourceCode """
ecmascript:

function initialize()
{
    CheckInit();
}

function CheckInit()
{
    if(!bInitialized)
    {
        bInitialized= true;  // Init() may call other functions that call CheckInit(). In that case it's better the flag is already set, otherwise an endless loop would occur.
        Init();
    }
}
function Init()
{
    destinationPos= initial_destinationPos;
    destinationOri= initial_destinationOri;

    BufferPos.length=
    BufferOri.length= cNumSupports;

    BufferPos[0]= initial_destinationPos;
    BufferOri[0]= initial_destinationOri;
    for(var C= 1; C<BufferPos.length; C++ )
    {
        BufferPos[C]= initial_valuePos;
        BufferOri[C]= initial_valueOri;
    }

    previousValuePos= initial_valuePos;
    previousValueOri= initial_valueOri;

    cStepTime= duration / cNumSupports;
}
function set_destinationPos(Dest, Now)
{
    CheckInit();

    destinationPos= Dest;
    // Somehow we assign to Buffer[-1] and wait untill this gets shifted into the real buffer.
    // Would we assign to Buffer[0] instead, we'd have no delay, but this would create a jump in the
    // output because Buffer[0] is associated with a value in the past.

    //UpdateBuffer(Now);
}

function set_destinationOri(Dest, Now)
{
    CheckInit();

    destinationOri= Dest;
    // Somehow we assign to Buffer[-1] and wait untill this gets shifted into the real buffer.
    // Would we assign to Buffer[0] instead, we'd have no delay, but this would create a jump in the
    // output because Buffer[0] is associated with a value in the past.

    //UpdateBuffer(Now);
}
function Tick(Now)
{
    CheckInit();

    if(!BufferEndTime)
    {
        BufferEndTime= Now; // first event we received, so we are in the initialization phase.

        valuePos_changed= initial_valuePos;
        valueOri_changed= initial_valueOri;
        return;
    }

    var Frac= UpdateBuffer(Now);
    // Frac is a value in   0 <= Frac < 1.

    // Now we can calculate the output.
    // This means we calculate the delta between each entry in Buffer and its previous
    // entries, calculate the step response of each such step and add it to form the output.

    // The oldest vaule Buffer[Buffer.length - 1] needs some extra thought, because it has
    // no previous value. More exactly, we haven't stored a previous value anymore.
    // However, the step response of that missing previous value has already reached its
    // destination, so we can - would we have that previous value - use this as a start point
    // for adding the step responses.
    // Actually UpdateBuffer(.) maintains this value in

    var OutputPos= previousValuePos;
    var OutputOri= previousValueOri;

    var DeltaInPos= BufferPos[BufferPos.length - 1].subtract(previousValuePos);
    var DeltaInOri= previousValueOri.inverse().multiply(BufferOri[BufferOri.length - 1]);

    var DeltaOutPos= DeltaInPos.multiply(StepResponse((BufferPos.length - 1 + Frac) * cStepTime));

    OutputPos= OutputPos.add(DeltaOutPos);
    OutputOri= OutputOri.slerp(OutputOri.multiply(DeltaInOri), StepResponse((BufferOri.length - 1 + Frac) * cStepTime));

    for(var C= BufferPos.length - 2; C>=0; C-- )
    {
        var DeltaInPos= BufferPos[C].subtract(BufferPos[C + 1]);
        var DeltaInOri= BufferOri[C + 1].inverse().multiply(BufferOri[C]);

        var DeltaOutPos= DeltaInPos.multiply(StepResponse((C + Frac) * cStepTime));

        OutputPos= OutputPos.add(DeltaOutPos);
        OutputOri= OutputOri.slerp(OutputOri.multiply(DeltaInOri), StepResponse((C + Frac) * cStepTime));
    }
    if(OutputPos != valuePos_changed)
        valuePos_changed= OutputPos;

    if(OutputOri != valueOri_changed)
        valueOri_changed= OutputOri;
}
function UpdateBuffer(Now)
{
    var Frac= (Now - BufferEndTime) / cStepTime;
    // is normally < 1. When it has grown to be larger than 1, we have to shift the array because the step response
    // of the oldest entry has already reached its destination, and it's time for a newer entry.
    // has already reached it
    // In the case of a very low frame rate, or a very short cStepTime we may need to shift by more than one entry.

    if(Frac >= 1)
    {
        var NumToShift= Math.floor(Frac);
        Frac-= NumToShift;

        if(NumToShift < BufferPos.length)
        {   // normal case.

            previousValuePos= BufferPos[BufferPos.length - NumToShift];
            previousValueOri= BufferOri[BufferOri.length - NumToShift];

            for(var C= BufferPos.length - 1; C>=NumToShift; C-- )
            {
                BufferPos[C]= BufferPos[C - NumToShift];
                BufferOri[C]= BufferOri[C - NumToShift];
            }

            for(var C= 0; C<NumToShift; C++ )
            {
                // Hmm, we have a destination value, but don't know how it has
                // reached the current state.
                // Therefore we do a linear interpolation from the latest value in the buffer to destination.

                var Alpha= C / NumToShift;

                BufferPos[C]= BufferPos[NumToShift].multiply(Alpha).add(destinationPos.multiply((1 - Alpha)));
                BufferOri[C]= destinationOri.slerp(BufferOri[NumToShift], Alpha);
            }
        }else
        {
            // degenerated case:
            //
            // We have a _VERY_ low frame rate...
            // we can only guess how we should fill the array.
            // Maybe we could write part of a linear interpolation
            // from Buffer[0] to destination, that goes from BufferEndTime to Now
            // (possibly only the end of the interpolation is to be written),
            // but if we rech here we are in a very degenerate case...
            // Thus we just write destination to the buffer.

            previousValuePos= NumToShift == BufferPos.length? BufferPos[0] : destinationPos;
            previousValueOri= NumToShift == BufferOri.length? BufferOri[0] : destinationOri;

            for(var C= 0; C<BufferPos.length; C++ )
            {
                BufferPos[C]= destinationPos;
                BufferOri[C]= destinationOri;
            }
        }
        BufferEndTime+= NumToShift * cStepTime;
    }
    return Frac;
}
function StepResponse(t)
{
    if(t < 0)
        return 0;

    if(t > duration)
        return 1;

    // When optimizing for speed, the above two if(.) cases can be omitted,
    // as this funciton will not be called for values outside of 0..duration.

    return StepResponseCore(t / duration);
}


// This function defines the shape of how the output responds to the input.
// It must accept values for T in the range 0 <= T <= 1.
// In order to create a smooth animation, it should return 0 for T == 0,
// 1 for T == 1 and be sufficient smooth in the range 0 <= T <= 1.

// It should be optimized for speed, in order for high performance. It's
// executed Buffer.length + 1 times each simulation tick.
function StepResponseCore(T)
{
    return .5 - .5 * Math.cos(T * Math.PI);
}

// The following functions are not used. They provide other responses (for fun).
function StepResponseCoreF(T)
{
    var cTau= .3;
    var cFrequency= 2.5;
    return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (1 - T);
//      return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (1 - T) * (1 - T);
//      return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (.5 + .5 * Math.cos(T * Math.PI));
//      return 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (.5 + .5 * Math.cos(T * Math.PI))* (.5 + .5 * Math.cos(T * Math.PI));
}
function StepResponseCoreE(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

    var cFrequency= 2.5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.sin(Math.sqrt(1 - T) * Math.PI/2);

    return A * .8 + B * .2;
}
function StepResponseCoreD(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

    var cFrequency= 2.5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.sin((1 - T) * Math.PI/2);

    return A * .8 + B * .2;
}
function StepResponseCoreC(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

    var cTau= .3;
    var cFrequency= 5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) * Math.exp(-T / cTau) * (1 - T);

    return A * .8 + B * .2;
}


function StepResponseCoreB(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

    var cTau= .3;
    var cFrequency= 5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) /** Math.exp(-T / cTau)*/ * (1 - T);

    return A * .8 + B * .2;
}
function StepResponseCoreA(T)
{
    var A= .5 - .5 * Math.cos(T * Math.PI);

    var cTau= .3;
    var cFrequency= 5;
    var B= 1 - Math.cos(T * 2 * Math.PI * cFrequency) /** Math.exp(-T / cTau)*/ * (1 - T);

    var Alpha= .2 * T;
    return A * (1 - Alpha) + B * Alpha;
}
""" .
:field_2_5_2_1_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'previousValueOri' ;
  x3do:type 'SFRotation' ;
  x3do:value ( 0.0 0.0 1.0 0.0 ) .
:field_2_5_2_1_2 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'Tick' ;
  x3do:type 'SFTime' .
:field_2_5_2_1_3 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'duration' ;
  x3do:type 'SFTime' .
:field_2_5_2_1_4 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_destinationOri' ;
  x3do:type 'SFRotation' .
:field_2_5_2_1_5 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'bInitialized' ;
  x3do:type 'SFBool' ;
  x3do:value false .
:field_2_5_2_1_6 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_valueOri' ;
  x3do:type 'SFRotation' .
:field_2_5_2_1_7 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'previousValuePos' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:field_2_5_2_1_8 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'destinationOri' ;
  x3do:type 'SFRotation' ;
  x3do:value ( 0.0 0.0 1.0 0.0 ) .
:field_2_5_2_1_9 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_valueOri' ;
  x3do:type 'SFRotation' .
:field_2_5_2_1_10 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_destinationPos' ;
  x3do:type 'SFVec3f' .
:field_2_5_2_1_11 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'BufferEndTime' ;
  x3do:type 'SFTime' ;
  x3do:value '0.0' .
:field_2_5_2_1_12 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'cNumSupports' ;
  x3do:type 'SFInt32' ;
  x3do:value 10 .
:field_2_5_2_1_13 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_valuePos' ;
  x3do:type 'SFVec3f' .
:field_2_5_2_1_14 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'cStepTime' ;
  x3do:type 'SFTime' ;
  x3do:value '0.0' .
:field_2_5_2_1_15 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_destinationOri' ;
  x3do:type 'SFRotation' .
:field_2_5_2_1_16 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'BufferOri' ;
  x3do:type 'MFRotation' .
:field_2_5_2_1_17 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'destinationPos' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:field_2_5_2_1_18 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_valuePos' ;
  x3do:type 'SFVec3f' .
:field_2_5_2_1_19 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'valuePos_changed' ;
  x3do:type 'SFVec3f' .
:field_2_5_2_1_20 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'isActive' ;
  x3do:type 'SFBool' .
:field_2_5_2_1_21 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_destinationPos' ;
  x3do:type 'SFVec3f' .
:field_2_5_2_1_22 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'valueOri_changed' ;
  x3do:type 'SFRotation' .
:field_2_5_2_1_23 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'BufferPos' ;
  x3do:type 'MFVec3f' .
:IS_2_5_2_1_24 a owl:NamedIndividual, x3do:IS ;
  x3do:hasParent :ScreenPositionDamper_PlacementChaser ;
  x3do:hasConnect :connect_2_5_2_1_24_1, :connect_2_5_2_1_24_2, :connect_2_5_2_1_24_3, :connect_2_5_2_1_24_4, :connect_2_5_2_1_24_5, :connect_2_5_2_1_24_6, :connect_2_5_2_1_24_7, :connect_2_5_2_1_24_8, :connect_2_5_2_1_24_9, :connect_2_5_2_1_24_10, :connect_2_5_2_1_24_11, :connect_2_5_2_1_24_12 .
:connect_2_5_2_1_24_1 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_5_2_1_24 ;
  x3do:nodeField 'duration' ;
  x3do:protoField 'duration' .
:connect_2_5_2_1_24_2 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_5_2_1_24 ;
  x3do:nodeField 'set_destinationOri' ;
  x3do:protoField 'set_destinationOri' .
:connect_2_5_2_1_24_3 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_5_2_1_24 ;
  x3do:nodeField 'set_valueOri' ;
  x3do:protoField 'set_valueOri' .
:connect_2_5_2_1_24_4 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_5_2_1_24 ;
  x3do:nodeField 'initial_valueOri' ;
  x3do:protoField 'initial_valueOri' .
:connect_2_5_2_1_24_5 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_5_2_1_24 ;
  x3do:nodeField 'set_destinationPos' ;
  x3do:protoField 'set_destinationPos' .
:connect_2_5_2_1_24_6 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_5_2_1_24 ;
  x3do:nodeField 'set_valuePos' ;
  x3do:protoField 'set_valuePos' .
:connect_2_5_2_1_24_7 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_5_2_1_24 ;
  x3do:nodeField 'initial_destinationOri' ;
  x3do:protoField 'initial_destinationOri' .
:connect_2_5_2_1_24_8 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_5_2_1_24 ;
  x3do:nodeField 'initial_valuePos' ;
  x3do:protoField 'initial_valuePos' .
:connect_2_5_2_1_24_9 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_5_2_1_24 ;
  x3do:nodeField 'valuePos_changed' ;
  x3do:protoField 'valuePos_changed' .
:connect_2_5_2_1_24_10 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_5_2_1_24 ;
  x3do:nodeField 'isActive' ;
  x3do:protoField 'isActive' .
:connect_2_5_2_1_24_11 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_5_2_1_24 ;
  x3do:nodeField 'initial_destinationPos' ;
  x3do:protoField 'initial_destinationPos' .
:connect_2_5_2_1_24_12 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_5_2_1_24 ;
  x3do:nodeField 'valueOri_changed' ;
  x3do:protoField 'valueOri_changed' .
:Tmer_PlacementChaser a owl:NamedIndividual, x3do:TimeSensor ;
  x3do:hasParent :ProtoBody_2_5_2 ;
  x3do:DEF 'Tmer_PlacementChaser' ;
  x3do:loop true .
:ROUTE_2_5_2_3 a owl:NamedIndividual, x3do:ROUTE ;
  x3do:hasParent :ProtoBody_2_5_2 ;
  x3do:fromField 'time' ;
  x3do:fromNode 'Tmer_PlacementChaser' ;
  x3do:toField 'Tick' ;
  x3do:toNode 'ScreenPositionDamper_PlacementChaser' .
:LastNode a owl:NamedIndividual, x3do:Script ;
  x3do:hasParent :ProtoBody_2_5_2 ;
  x3do:hasField :field_2_5_2_4_1 ;
  x3do:hasIS :IS_2_5_2_4_2 ;
  x3do:DEF 'LastNode' ;
  x3do:sourceCode """
ecmascript:

function initialize()
{
    isLoaded= true;
}
""" .
:field_2_5_2_4_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :LastNode ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'isLoaded' ;
  x3do:type 'SFBool' .
:IS_2_5_2_4_2 a owl:NamedIndividual, x3do:IS ;
  x3do:hasParent :LastNode ;
  x3do:hasConnect :connect_2_5_2_4_2_1 .
:connect_2_5_2_4_2_1 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_5_2_4_2 ;
  x3do:nodeField 'isLoaded' ;
  x3do:protoField 'isLoaded' .
:ProtoDeclare_2_6 a owl:NamedIndividual, x3do:ProtoDeclare ;
  x3do:hasParent :Scene ;
  x3do:hasProtoInterface :ProtoInterface_2_6_1 ;
  x3do:hasProtoBody :ProtoBody_2_6_2 ;
  x3do:name 'PositionDamper' .
:ProtoInterface_2_6_1 a owl:NamedIndividual, x3do:ProtoInterface ;
  x3do:hasParent :ProtoDeclare_2_6 ;
  x3do:hasField :field_2_6_1_1, :field_2_6_1_2, :field_2_6_1_3, :field_2_6_1_4, :field_2_6_1_5, :field_2_6_1_6, :field_2_6_1_7, :field_2_6_1_8, :field_2_6_1_9, :field_2_6_1_10, :field_2_6_1_11, :field_2_6_1_12, :field_2_6_1_13, :field_2_6_1_14 .
:field_2_6_1_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'isLoaded' ;
  x3do:type 'SFBool' .
:field_2_6_1_2 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'value_changed' ;
  x3do:type 'SFVec3f' .
:field_2_6_1_3 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_1 ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_destination' ;
  x3do:type 'SFVec3f' .
:field_2_6_1_4 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'takeFirstInput' ;
  x3do:type 'SFBool' ;
  x3do:value true .
:field_2_6_1_5 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_destination' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:field_2_6_1_6 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'order' ;
  x3do:type 'SFInt32' ;
  x3do:value 1 .
:field_2_6_1_7 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'credits' ;
  x3do:type 'MFString' ;
  x3do:value '"Initial idea and copyright by Herbert Stocker http://www.hersto.net/"' .
:field_2_6_1_8 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'reachThreshold' ;
  x3do:type 'SFFloat' ;
  x3do:value 0.01 .
:field_2_6_1_9 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_1 ;
  x3do:accessType 'inputOutput' ;
  x3do:name 'tau' ;
  x3do:type 'SFFloat' ;
  x3do:value 1.0 .
:field_2_6_1_10 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_1 ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_value' ;
  x3do:type 'SFVec3f' .
:field_2_6_1_11 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'reached' ;
  x3do:type 'SFBool' .
:field_2_6_1_12 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_value' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:field_2_6_1_13 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'isActive' ;
  x3do:type 'SFBool' .
:field_2_6_1_14 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'eps' ;
  x3do:type 'SFFloat' ;
  x3do:value 0.0010 .
:ProtoBody_2_6_2 a owl:NamedIndividual, x3do:ProtoBody ;
  x3do:hasParent :ProtoDeclare_2_6 ;
  x3do:hasProtoDeclare :ProtoDeclare_2_6_2_1 ;
  x3do:hasChildren :EFFS, :Worker, :Timer_PositionDamper ;
  x3do:hasROUTE :ROUTE_2_6_2_5, :ROUTE_2_6_2_6 .
:ProtoDeclare_2_6_2_1 a owl:NamedIndividual, x3do:ProtoDeclare ;
  x3do:hasParent :ProtoBody_2_6_2 ;
  x3do:hasProtoInterface :ProtoInterface_2_6_2_1_1 ;
  x3do:hasProtoBody :ProtoBody_2_6_2_1_2 ;
  x3do:name 'EFFS' .
:ProtoInterface_2_6_2_1_1 a owl:NamedIndividual, x3do:ProtoInterface ;
  x3do:hasParent :ProtoDeclare_2_6_2_1 ;
  x3do:hasField :field_2_6_2_1_1_1 .
:field_2_6_2_1_1_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_6_2_1_1 ;
  x3do:accessType 'inputOutput' ;
  x3do:name 'tau' ;
  x3do:type 'SFFloat' ;
  x3do:value 1.0 .
:ProtoBody_2_6_2_1_2 a owl:NamedIndividual, x3do:ProtoBody ;
  x3do:hasParent :ProtoDeclare_2_6_2_1 ;
  x3do:hasChildren :Group_2_6_2_1_2_1 .
:Group_2_6_2_1_2_1 a owl:NamedIndividual, x3do:Group ;
  x3do:hasParent :ProtoBody_2_6_2_1_2 .
:EFFS a owl:NamedIndividual, x3do:ProtoInstance ;
  x3do:hasParent :ProtoBody_2_6_2 ;
  x3do:hasFieldValue :fieldValue_2_6_2_2_1 ;
  x3do:DEF 'EFFS' ;
  x3do:name 'EFFS' .
:fieldValue_2_6_2_2_1 a owl:NamedIndividual, x3do:fieldValue ;
  x3do:hasParent :EFFS ;
  x3do:name 'tau' ;
  x3do:value 1.0 .
:Worker a owl:NamedIndividual, x3do:Script ;
  x3do:hasParent :ProtoBody_2_6_2 ;
  x3do:hasField :field_2_6_2_3_1, :field_2_6_2_3_2, :field_2_6_2_3_3, :field_2_6_2_3_4, :field_2_6_2_3_5, :field_2_6_2_3_6, :field_2_6_2_3_7, :field_2_6_2_3_8, :field_2_6_2_3_9, :field_2_6_2_3_10, :field_2_6_2_3_11, :field_2_6_2_3_12, :field_2_6_2_3_13, :field_2_6_2_3_14, :field_2_6_2_3_15, :field_2_6_2_3_16, :field_2_6_2_3_17, :field_2_6_2_3_18, :field_2_6_2_3_19, :field_2_6_2_3_20, :field_2_6_2_3_21, :field_2_6_2_3_22, :field_2_6_2_3_23, :field_2_6_2_3_24 ;
  x3do:hasIS :IS_2_6_2_3_25 ;
  x3do:DEF 'Worker' ;
  x3do:sourceCode """
ecmascript:

function StartTimer()
{
    if(IsCortona)
        return;

    if(!needTimer)
    {
        lastTick= 0;
        needTimer= true;
    }
}

function StopTimer()
{
    if(IsCortona)
        return;

    if(needTimer)
    {
        needTimer= false;
    }
}

function initialize()
{
    CheckInit();
}

function CheckInit()
{
    if(!bInitialized)
    {
        bInitialized= true;
        Init();
    }

}

function Init()
{
    IsCortona= false && Browser.getName().indexOf('Cortona') != -1;

    bNeedToTakeFirstInput= takeFirstInput;

    tau= effs.tau;
    set_value(initial_value);
    if(IsCortona)
        needTimer= true;
    else
        needTimer=    input.x != initial_value.x
                   || input.y != initial_value.y
                   || input.z != initial_value.z
                   ;
}

function set_tau(t)
{
    CheckInit();

    tau= t;
}

function set_destination(i)
{
    CheckInit();

    if(bNeedToTakeFirstInput)
    {
        bNeedToTakeFirstInput= false;
        set_value(i);
    }


    if(i != input)
    {
        input= i;
        StartTimer();
    }
}

function set_value(o)
{
    CheckInit();

    bNeedToTakeFirstInput= false;

    value1= value2= value3= value4= value5= o;
    value_changed= o;
    UpdateReached();
    StartTimer();
}

function tick(now)
{
    CheckInit();

    if(!lastTick)
    {
        lastTick= now;
        return;
    }

    var delta= now - lastTick;
    lastTick= now;

    var alpha= Math.exp(-delta / tau);


    if(bNeedToTakeFirstInput)  // then don't do any processing.
        return;

    value1= order > 0 && tau
               ? input  .add(value1.subtract(input  ).multiply(alpha))
               : input;

    value2= order > 1 && tau
               ? value1.add(value2.subtract(value1).multiply(alpha))
               : value1;

    value3= order > 2 && tau
               ? value2.add(value3.subtract(value2).multiply(alpha))
               : value2;

    value4= order > 3 && tau
               ? value3.add(value4.subtract(value3).multiply(alpha))
               : value3;

    value5= order > 4 && tau
               ? value4.add(value5.subtract(value4).multiply(alpha))
               : value4;

    var dist= GetDist();

    if(dist < eps)
    {
        value1= value2= value3= value4= value5= input;

        value_changed= input;
        UpdateReached2(dist);

        StopTimer();
        return;
    }
    value_changed= value5;
    UpdateReached2(dist);

}

function GetDist()
{
    var dist= value1.subtract(input).length();
    if(order > 1)
    {
        var dist2= value2.subtract(value1).length();
        if( dist2 > dist)  dist= dist2;
    }
    if(order > 2)
    {
        var dist3= value3.subtract(value2).length();
        if( dist3 > dist)  dist= dist3;
    }
    if(order > 3)
    {
        var dist4= value4.subtract(value3).length();
        if( dist4 > dist)  dist= dist4;
    }
    if(order > 4)
    {
        var dist5= value5.subtract(value4).length();
        if( dist5 > dist)  dist= dist5;
    }
    return dist;
}

function UpdateReached()
{
    return UpdateReached2(GetDist());
}

function UpdateReached2(Dist)
{
    if(reached)
    {
        if(Dist > reachThreshold)
            reached= false;
    }else
    {
        if(Dist <= reachThreshold)
            reached= true;
    }
}
""" .
:field_2_6_2_3_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_value' ;
  x3do:type 'SFVec3f' .
:field_2_6_2_3_2 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'IsCortona' ;
  x3do:type 'SFBool' ;
  x3do:value false .
:field_2_6_2_3_3 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'bInitialized' ;
  x3do:type 'SFBool' ;
  x3do:value false .
:field_2_6_2_3_4 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'reachThreshold' ;
  x3do:type 'SFFloat' .
:field_2_6_2_3_5 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'lastTick' ;
  x3do:type 'SFTime' ;
  x3do:value '0.0' .
:field_2_6_2_3_6 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'bNeedToTakeFirstInput' ;
  x3do:type 'SFBool' ;
  x3do:value true .
:field_2_6_2_3_7 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'value5' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:field_2_6_2_3_8 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'value4' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:field_2_6_2_3_9 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'value3' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:field_2_6_2_3_10 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'value2' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:field_2_6_2_3_11 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'input' ;
  x3do:type 'SFVec3f' .
:field_2_6_2_3_12 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'value1' ;
  x3do:type 'SFVec3f' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:field_2_6_2_3_13 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'eps' ;
  x3do:type 'SFFloat' .
:field_2_6_2_3_14 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_destination' ;
  x3do:type 'SFVec3f' .
:field_2_6_2_3_15 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'value_changed' ;
  x3do:type 'SFVec3f' .
:field_2_6_2_3_16 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'tau' ;
  x3do:type 'SFFloat' ;
  x3do:value 1.0 .
:field_2_6_2_3_17 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:hasChildren :EFFS-USE-1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'effs' ;
  x3do:type 'SFNode' .
:EFFS-USE-1 a owl:NamedIndividual, x3do:ProtoInstance ;
  x3do:hasParent :field_2_6_2_3_17 ;
  owl:sameAs :EFFS . # DEF matching this USE
:field_2_6_2_3_18 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'order' ;
  x3do:type 'SFInt32' .
:field_2_6_2_3_19 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'needTimer' ;
  x3do:type 'SFBool' .
:field_2_6_2_3_20 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'tick' ;
  x3do:type 'SFTime' .
:field_2_6_2_3_21 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_tau' ;
  x3do:type 'SFFloat' .
:field_2_6_2_3_22 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'initial_value' ;
  x3do:type 'SFVec3f' .
:field_2_6_2_3_23 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'reached' ;
  x3do:type 'SFBool' .
:field_2_6_2_3_24 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :Worker ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'takeFirstInput' ;
  x3do:type 'SFBool' .
:IS_2_6_2_3_25 a owl:NamedIndividual, x3do:IS ;
  x3do:hasParent :Worker ;
  x3do:hasConnect :connect_2_6_2_3_25_1, :connect_2_6_2_3_25_2, :connect_2_6_2_3_25_3, :connect_2_6_2_3_25_4, :connect_2_6_2_3_25_5, :connect_2_6_2_3_25_6, :connect_2_6_2_3_25_7, :connect_2_6_2_3_25_8, :connect_2_6_2_3_25_9, :connect_2_6_2_3_25_10, :connect_2_6_2_3_25_11 .
:connect_2_6_2_3_25_1 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_6_2_3_25 ;
  x3do:nodeField 'set_value' ;
  x3do:protoField 'set_value' .
:connect_2_6_2_3_25_2 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_6_2_3_25 ;
  x3do:nodeField 'reachThreshold' ;
  x3do:protoField 'reachThreshold' .
:connect_2_6_2_3_25_3 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_6_2_3_25 ;
  x3do:nodeField 'input' ;
  x3do:protoField 'initial_destination' .
:connect_2_6_2_3_25_4 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_6_2_3_25 ;
  x3do:nodeField 'eps' ;
  x3do:protoField 'eps' .
:connect_2_6_2_3_25_5 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_6_2_3_25 ;
  x3do:nodeField 'set_destination' ;
  x3do:protoField 'set_destination' .
:connect_2_6_2_3_25_6 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_6_2_3_25 ;
  x3do:nodeField 'value_changed' ;
  x3do:protoField 'value_changed' .
:connect_2_6_2_3_25_7 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_6_2_3_25 ;
  x3do:nodeField 'order' ;
  x3do:protoField 'order' .
:connect_2_6_2_3_25_8 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_6_2_3_25 ;
  x3do:nodeField 'needTimer' ;
  x3do:protoField 'isActive' .
:connect_2_6_2_3_25_9 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_6_2_3_25 ;
  x3do:nodeField 'initial_value' ;
  x3do:protoField 'initial_value' .
:connect_2_6_2_3_25_10 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_6_2_3_25 ;
  x3do:nodeField 'reached' ;
  x3do:protoField 'reached' .
:connect_2_6_2_3_25_11 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_6_2_3_25 ;
  x3do:nodeField 'takeFirstInput' ;
  x3do:protoField 'takeFirstInput' .
:Timer_PositionDamper a owl:NamedIndividual, x3do:TimeSensor ;
  x3do:hasParent :ProtoBody_2_6_2 ;
  x3do:DEF 'Timer_PositionDamper' ;
  x3do:loop true .
:ROUTE_2_6_2_5 a owl:NamedIndividual, x3do:ROUTE ;
  x3do:hasParent :ProtoBody_2_6_2 ;
  x3do:fromField 'needTimer' ;
  x3do:fromNode 'Worker' ;
  x3do:toField 'enabled' ;
  x3do:toNode 'Timer_PositionDamper' .
:ROUTE_2_6_2_6 a owl:NamedIndividual, x3do:ROUTE ;
  x3do:hasParent :ProtoBody_2_6_2 ;
  x3do:fromField 'time' ;
  x3do:fromNode 'Timer_PositionDamper' ;
  x3do:toField 'tick' ;
  x3do:toNode 'Worker' .
