(function(){
	/**
	 * ClientKeyframeAnimation implementation
	 * @param{string} name name of the animation
	 * @param{Array.<number>} keys keys
	 * @param{Array.<number>|undefined} positionValues
	 * @param{Array.<number>|undefined} orientationValues
	 * @constructor
	 * @implements{MotionFactory}
	 */
	function ClientKeyframeAnimation(name, keys, positionValues, orientationValues, opt){

		/**
		 * name of animation
		 * @private
		 * @type {string}
		 */
		this.name = name;
		/**
		 * Array of the keys
		 * @private
		 * @type{Array.<number>}
		 */
		this.keys = keys;
		/**
		 * Array fo the position values
		 * @private
		 * @type{Array.<number>|undefined}
		 */
		this.positionValues = positionValues;
		/**
		 * Array of the orientation values
		 * @private
		 * @type{Array.<number>|undefined}
		 */
		this.orientationValues = orientationValues;
		
		//options - set defaults
		/**
		 * loop
		 * @private
		 * @type {number}
		 */
		this.loop = 1;
		/**
		 * delay
		 * @private
		 * @type{number}
		 */
		this.delay = 0;
		/**
		 * Duration of the animation
		 * @private
		 * @type {number}
		 */
		this.duration = 1000;
		/**
		 * easing
		 * @private
		 * @type {function}
		 */
		this.easing = TWEEN.Easing.Linear.None;
		/**
		 * Callback, executed as soon as the animation ended
		 * @private
		 * @type {function}
		 */
		this.callback = function(){};
		if(opt){
			this.setOptions(opt);
		}
	};

	var k = ClientKeyframeAnimation.prototype;

	/** @inheritDoc */
	k.applyAnimation = function(animatable, currentTime, startTime, endTime, easing){
		var t = (currentTime - startTime) / (endTime - startTime);
		if(typeof(easing) === "function") t = easing(t); //otherwise its linear
		var l = this.keys.length - 1;
		if (t <= this.keys[0]){
			this.setValue( animatable, this.getPosition(0), this.getOrientation(0) );
		}else if (t >= this.keys[l - 1]){
			this.setValue( animatable, this.getPosition(l), this.getOrientation(l) );
		}else{
			for ( var i = 0; i < l - 1; i++){
				if (this.keys[i] < t && t <= this.keys[i + 1]) {
					var p = (t - this.keys[i]) / (this.keys[i + 1] - this.keys[i]);
					this.setValue( animatable, this.getInterpolatedPosition(i, p), this.getInterpolatedOrientation(i, p) );
				}
			}
		}
	};

	/**
	 * Set position and animation of the animatable
	 * @private
	 * @param {Array.<number>|undefined}
	 * @param {Array.<number>|undefined}
	 */
	k.setValue = function(animatable, position, orientation){
		if(position != undefined)
			animatable.setPosition(position);
		if(orientation != undefined)
			animatable.setOrientation(orientation);
	};

	/**
	 * Interpolates keyvalues between index i and index i+1 with parameter t
	 * @private
	 * @param {number} index
	 * @param {number} t interpolationparameter
	 * @return {Array.<number>} Position
	 */
	k.getInterpolatedPosition = function(index, t){
		if(this.positionValues === undefined) return undefined;
		var ret = [];
		var start = this.getPosition(index);
		var end = this.getPosition(index+1);
		var i = 0;
		for(i=0; i<start.length; i++ ){
			ret[i] = start[i] + ( end[i] - start[i] ) * t;
		}
		return ret;
	};

	/**
	 * Interpolates keyvalues between index i and index i+1 with parameter t
	 * @private
	 * @param {number} index
	 * @param {number} t interpolationparameter
	 * @return {Array.<number>} Orientation
	 */
	k.getInterpolatedOrientation = function(index, t){
		if(this.orientationValues === undefined) return undefined;
		//var ret = [];
		var start = this.getOrientation(index);
		var end = this.getOrientation(index+1);
		var quaternionStart = new XML3DRotation();
		quaternionStart.setQuaternion( new XML3DVec3(start[0],start[1],start[2]), start[3] );
		var quaternionEnd = new XML3DRotation();
		quaternionEnd.setQuaternion( new XML3DVec3(end[0],end[1],end[2]), end[3] );
		var ret = quaternionStart.interpolate(quaternionEnd, t);
		/*var i = 0;
		for(i=0; i<start.length; i++ ){
			ret[i] = start[i] + ( end[i] - start[i] ) * t;
		}*/
		return [ret._data[0], ret._data[1], ret._data[2], ret._data[3]];
	};

	/**
	 * Gets a position corresponding to a key
	 * @private
	 * @param {number} key
	 * @return {Array.<number>} Position
	 */
	k.getPosition = function(key){
		if(this.positionValues === undefined || key > this.keys.length-1 /*just in case*/) return undefined;
		var index = key*3;
		return [ this.positionValues[index], this.positionValues[index+1], this.positionValues[index+2] ];
	};

	/**
	 * Gets an orientation corresponding to a key
	 * @private
	 * @param {number} key
	 * @return {Array.<number>} Orientation
	 */
	k.getOrientation = function(key){
		if(this.orientationValues === undefined || key > this.keys.length-1 /*just in case*/) return undefined;
		var index = key*4;
		return [ this.orientationValues[index], this.orientationValues[index+1], this.orientationValues[index+2], this.orientationValues[index+3] ];
	};

    /** @inheritDoc */
    k.setOptions = function(opt){
		if(opt.loop)
			this.loop = opt.loop;
		if(opt.duration)
			this.duration = opt.duration;
		if(opt.easingk && typeof(opt.easing) === "function")
			this.easing = opt.easing;
		if(opt.callback && typeof(opt.callback) === "function")
			this.callback = opt.callback;
    };

	//export
	XMOT.ClientKeyframeAnimation = ClientKeyframeAnimation;
}());
@@ -3445,26 +3445,8 @@
 ed;%0A
-%09%09//var ret = %5B%5D;%0A
 %09%09va
@@ -3531,489 +3531,126 @@
 ;%0A%09%09
-var quaternionStart = new XML3DRotation();%0A%09%09quaternionStart.setQuaternion( new XML3DVec3(start%5B0%5D,start%5B1%5D,start%5B2%5D), start%5B3%5D );%0A%09%09var quaternionEnd = new XML3DRotation();%0A%09%09quaternionEnd.setQuaternion( new XML3DVec3(end%5B0%5D,end%5B1%5D,end%5B2%5D), end%5B3%5D );%0A%09%09var ret = quaternionStart.interpolate(quaternionEnd, t);%0A%09%09/*var i = 0;%0A%09%09for(i=0; i%3Cstart.length; i++ )%7B%0A%09%09%09ret%5Bi%5D = start%5Bi%5D + ( end%5Bi%5D - start%5Bi%5D ) * t;%0A%09%09%7D*/%0A%09%09return %5Bret._data%5B0%5D, ret._data%5B1%5D, ret._data%5B2%5D, ret._data%5B3%5D%5D
+//the newely created quat gets filled with the result and returned%0A%09%09return quat4.slerp(start, end, t, quat4.create())
 ;%0A%09%7D

Use quat4 instead of xml3drotation for the slerp