lib/Oimo.js
function(timeStep){
        switch(this.type){
            case this.BODY_STATIC:
                this.linearVelocity.init();
                this.angularVelocity.init();
                // ONLY FOR TEST
                if(this.controlPos){
                    this.position.copy(this.newPosition);
                    this.controlPos = false;
                }
                if(this.controlRot){
                    this.orientation.copy(this.newOrientation);
                    this.controlRot = false;
                }
                /*this.linearVelocity.x=0;
                this.linearVelocity.y=0;
                this.linearVelocity.z=0;
                this.angularVelocity.x=0;
                this.angularVelocity.y=0;
                this.angularVelocity.z=0;*/
            break;
            case this.BODY_DYNAMIC:

                if(this.controlPos){
                    this.angularVelocity.init();
                    this.linearVelocity.init();
                    this.linearVelocity.x = (this.newPosition.x - this.position.x)/timeStep;
                    this.linearVelocity.y = (this.newPosition.y - this.position.y)/timeStep;
                    this.linearVelocity.z = (this.newPosition.z - this.position.z)/timeStep;
                    this.controlPos = false;
                }
                if(this.controlRot){
                    this.angularVelocity.init();
                    this.orientation.copy(this.newOrientation);

                    //var t=timeStep//*0.5;
                    //var q = new OIMO.Quat();
                    //q.sub(this.newOrientation, this.orientation);
                    //q.normalize(q);
                    /*q.s = (this.newOrientation.s - this.orientation.s)/t;
                    q.x = (this.newOrientation.x - this.orientation.x)/t;
                    q.y = (this.newOrientation.y - this.orientation.y)/t;
                    q.z = (this.newOrientation.z - this.orientation.z)/t;*/

                    //this.angularVelocity.applyQuaternion(q);
                    //this.angularVelocity.x = this.angularVelocity.x/t;
                    //this.angularVelocity.y = this.angularVelocity.y/t;
                    //this.angularVelocity.z = this.angularVelocity.z/t;

                    this.controlRot = false;
                }

                this.position.addTime(this.linearVelocity, timeStep);
                this.orientation.addTime(this.angularVelocity, timeStep);

            break;
            default:
                throw new Error("Invalid type.");
        }
        this.syncShapes();
    }
function(timeStep){
        switch(this.type){
            case this.BODY_STATIC:
                this.linearVelocity.init();
                this.angularVelocity.init();
                // ONLY FOR TEST
                if(this.controlPos){
                    this.position.copy(this.newPosition);
                    this.controlPos = false;
                }
                if(this.controlRot){
                    this.orientation.copy(this.newOrientation);
                    this.controlRot = false;
                }
                /*this.linearVelocity.x=0;
                this.linearVelocity.y=0;
                this.linearVelocity.z=0;
                this.angularVelocity.x=0;
                this.angularVelocity.y=0;
                this.angularVelocity.z=0;*/
            break;
            case this.BODY_DYNAMIC:

                if(this.controlPos){
                    this.angularVelocity.init();
                    this.linearVelocity.init();
                    this.linearVelocity.x = (this.newPosition.x - this.position.x)/timeStep;
                    this.linearVelocity.y = (this.newPosition.y - this.position.y)/timeStep;
                    this.linearVelocity.z = (this.newPosition.z - this.position.z)/timeStep;
                    this.controlPos = false;
                }
                if(this.controlRot){
                    this.angularVelocity.init();
                    this.orientation.copy(this.newOrientation);

                    //var t=timeStep//*0.5;
                    //var q = new OIMO.Quat();
                    //q.sub(this.newOrientation, this.orientation);
                    //q.normalize(q);
                    /*q.s = (this.newOrientation.s - this.orientation.s)/t;
                    q.x = (this.newOrientation.x - this.orientation.x)/t;
                    q.y = (this.newOrientation.y - this.orientation.y)/t;
                    q.z = (this.newOrientation.z - this.orientation.z)/t;*/

                    //this.angularVelocity.applyQuaternion(q);
                    //this.angularVelocity.x = this.angularVelocity.x/t;
                    //this.angularVelocity.y = this.angularVelocity.y/t;
                    //this.angularVelocity.z = this.angularVelocity.z/t;

                    this.controlRot = false;
                }

                this.position.addTime(this.linearVelocity, timeStep);
                this.orientation.addTime(this.angularVelocity, timeStep);

            break;
            default:
                throw new Error("Invalid type.");
        }
        this.syncShapes();
    }
function ( timeStep ) { switch ( this . type ) { case this . BODY_STATIC : this . linearVelocity . init ( ) ; this . angularVelocity . init ( ) ; // ONLY FOR TEST if ( this . controlPos ) { this . position . copy ( this . newPosition ) ; this . controlPos = false ; } if ( this . controlRot ) { this . orientation . copy ( this . newOrientation ) ; this . controlRot = false ; } /*this.linearVelocity.x=0;
                this.linearVelocity.y=0;
                this.linearVelocity.z=0;
                this.angularVelocity.x=0;
                this.angularVelocity.y=0;
                this.angularVelocity.z=0;*/ break ; case this . BODY_DYNAMIC : if ( this . controlPos ) { this . angularVelocity . init ( ) ; this . linearVelocity . init ( ) ; this . linearVelocity . x = ( this . newPosition . x - this . position . x ) / timeStep ; this . linearVelocity . y = ( this . newPosition . y - this . position . y ) / timeStep ; this . linearVelocity . z = ( this . newPosition . z - this . position . z ) / timeStep ; this . controlPos = false ; } if ( this . controlRot ) { this . angularVelocity . init ( ) ; this . orientation . copy ( this . newOrientation ) ; //var t=timeStep//*0.5; //var q = new OIMO.Quat(); //q.sub(this.newOrientation, this.orientation); //q.normalize(q); /*q.s = (this.newOrientation.s - this.orientation.s)/t;
                    q.x = (this.newOrientation.x - this.orientation.x)/t;
                    q.y = (this.newOrientation.y - this.orientation.y)/t;
                    q.z = (this.newOrientation.z - this.orientation.z)/t;*/ //this.angularVelocity.applyQuaternion(q); //this.angularVelocity.x = this.angularVelocity.x/t; //this.angularVelocity.y = this.angularVelocity.y/t; //this.angularVelocity.z = this.angularVelocity.z/t; this . controlRot = false ; } this . position . addTime ( this . linearVelocity , timeStep ) ; this . orientation . addTime ( this . angularVelocity , timeStep ) ; break ; default : throw new Error ( "Invalid type." ) ; } this . syncShapes ( ) ; }
The time integration of the motion of a rigid body, you can update the information such as the shape.
This method is invoked automatically when calling the step of the World,
There is no need to call from outside usually.
@param  timeStep time
The time integration of the motion of a rigid body you can update the information such as the shape . This method is invoked automatically when calling the step of the World There is no need to call from outside usually .