Camera zoom from one position to another position smoothly


#1

Hi,

In my project, after one step camera want to focus the entity, after few seconds it get back to the previous position and look at the table. At first camera focusing on the table it self. That means camera go to the target position and get back to the position.

For that i used slerp and lookat methods but its not working smooth. Can you help me in this case. Which help me to zoom smoothly.

Thank you.


#2

Hi,
maybe I have something for you:
https://github.com/FionNoir/PlayCanvasLib

There is a function lookAtHotspot which may fit your needs.

/**
 * Move Camera to 'resetPoint' and look at 'lookAtPoint'
 * @param resetPoint {entity} new camera position to move to
 * @param lookAtPoint {entity} new point to look at
 */
OrbitCamera.prototype.lookAtHotspot = function(resetPoint, lookAtPoint) {

    if(this.Goto)return;
        console.log("resetAndLookAtPoint");
        this._lockPivot.copy(lookAtPoint);          
        
        this.teCam.setPosition(resetPoint);            
        this.teCam.lookAt(lookAtPoint);              

        this.newDis.sub2(lookAtPoint, resetPoint);    

        this.startPos.copy(this.entity.getPosition());
        this.startRot.copy(this.entity.getRotation());
        this.targPos.copy(this.teCam.getPosition());
        this.targRot.copy(this.teCam.getRotation());       
        
        this._lockDist = this.newDis.length();                
        this._lockYaw = this._calcYaw(this.targRot);             
        this._lockPitch = this._calcPitch(this.targRot , this._targetYaw);
      
        
        this.Goto = true;
        this.GotoTimer = 0.0;
        
};

You can simply call them by using this.app.fire('lookAtHotspot', newCameraPositionEntity, newLookAtPoint)

I don’t know if this fits your needs, and I know it’s not a clean code but give a try. It’s a pity, that my privat account her has so less storage. Otherwise I would provide an example.