try Quaternion

test

by pkin159

HTML

<div>
    <button id='hitOnce' class='buttonClass'>Hit Once</button>
</div>
<div>
    <button id='playScore' class='buttonclass'>playscore</button>
    <button id='playScore1' class='buttonclass'>playscore1</button>
    <button id='returnBasic' class='buttonclass'>Basic</button>
</div>
<div>Set bpm
    <input id='bpm' value=120 style='width:6em'></input>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r70/three.min.js"></script>
<script src="https://dl.dropboxusercontent.com/u/3587259/Code/Threejs/OrbitControls.js">
    
</script>

CSS

#info {
    position: absolute;
    top: 0px;
    width: 100%;
    padding: 10px;
    text-align: center;
    color: #ffff00
}
body {
    overflow: hidden;
}

JavaScript

var frameStart, frameEnd;


var Stick = function () {
    // properties
    this.T = 4; // in seconds
    this.keys = [{   /////////will be change
        timeS: 0,
        value: 0
    }, {
        timeS: 0.25,
        value: 0.2//3.14 / 4
    }, {
        timeS: 0.3,
        value: -.2
    },
       {
        timeS: 0.5,
        value: 0
    },{
        timeS: 1,
        value: 0
    }
                ];

    this.frame1 = new THREE.Object3D();  // starting & ending frames
    this.frame2 = new THREE.Object3D();  // of startOneCycle
                                         // default frame1 = frame2 = frameChair.clone();
    
    this.startTime = 0;
    this.angle = 0; // for 'text-based' rendering
    this.instrument = 's';
    this.color = new THREE.Color(1,0,0);
    this.group = newMesh(this.color);
    this.object = new THREE.Object3D();
    this.object.add(this.group);
    // methods
    this.setT = function (period) {
        this.T = period;
    }
    this.setMaxKeysValue = function (intensity){
        this.keys[1].value = intensity;
    }

    this.interpolate = function (s) { // normalized time
        if (s > 1) // end of cycle
        return this.keys[this.keys.length - 1].value;

        for (var i = 1; i < this.keys.length; i++) {
            if (s < this.keys[i].timeS) break;
        }

        var vv = this.keys[i - 1].value + (s - this.keys[i - 1].timeS) / (this.keys[i].timeS - this.keys[i - 1].timeS) * (this.keys[i].value - this.keys[i - 1].value);
        return vv;
    };

    this.update = function (time) { // time: elapsedTime
        var s = (time - this.startTime) / this.T;
       
        this.tt = (this.tt + 0.01) || 0;

        this.angle = this.interpolate(s);
        this.group.rotation.x = this.angle;
        
        var quat = new THREE.Quaternion();
   		
        //console.log(this.tt);
         
        if(this.tt > 1){     
        	this.tt = 1;
        
        	THREE.Quaternion.slerp(this.frame1.quaternion,...