{
  "code": "var Vector3 = Laya.Vector3;\r\nimport { GameUtils } from \"../../GameUtils/GameUtils\";\r\nexport default class CameraManager extends Laya.Script {\r\n    constructor() {\r\n        super();\r\n        this.follow = false;\r\n        this.lookat = false;\r\n        this.offest = new Vector3();\r\n        this.curCameraPos = new Vector3();\r\n        this.startPos = new Vector3();\r\n        this.starRot = new Vector3();\r\n        this.forwardDistance = 2;\r\n        this.addspeed = 1;\r\n        this.followrate = 0.3;\r\n        this.lerpPos = new Vector3();\r\n        this.lerprot = new Laya.Quaternion();\r\n        this.lookdir = new Vector3();\r\n        this.offesty = 0;\r\n        this.offestz = 0;\r\n        CameraManager.CameraManagerInstance = this;\r\n    }\r\n    static get Instance() {\r\n        return CameraManager.CameraManagerInstance;\r\n    }\r\n    onAwake() {\r\n        this.camera = this.owner;\r\n    }\r\n    SetFollow(_target, _lookat = false) {\r\n        this.curTarget = _target;\r\n        Vector3.subtract(_target.position, this.camera.transform.position, this.offest);\r\n        this.follow = true;\r\n        this.lookat = _lookat;\r\n        this.startPos = this.camera.transform.position.clone();\r\n        this.starRot = this.camera.transform.rotationEuler.clone();\r\n        Laya.timer.clearAll(this);\r\n    }\r\n    StopFollow() {\r\n        this.follow = false;\r\n        this.curTarget = null;\r\n        this.offesty = 0;\r\n        this.offestz = 0;\r\n        this.offest = new Vector3(0, 0, 0);\r\n        this.curCameraPos = new Vector3(0, 0, 0);\r\n        this.lerpPos = new Vector3(0, 0, 0);\r\n    }\r\n    PauseFollow() {\r\n        this.follow = false;\r\n    }\r\n    ResumeFollow() {\r\n        this.follow = true;\r\n    }\r\n    onUpdate() {\r\n        if (this.follow && this.curTarget) {\r\n            Vector3.subtract(this.curTarget.position, this.offest, this.curCameraPos);\r\n            this.offesty = GameUtils.lerp(this.offesty, 1, 0.02);\r\n            this.curCameraPos = new Vector3(this.curCameraPos.x, this.curCameraPos.y + this.offesty, this.curCameraPos.z + this.offestz);\r\n            Vector3.lerp(this.camera.transform.position, this.curCameraPos, this.followrate, this.lerpPos);\r\n            this.camera.transform.position = new Vector3(this.curCameraPos.x, this.lerpPos.y, this.lerpPos.z);\r\n            var quaternion1 = new Laya.Quaternion();\r\n            var lookpos = new Vector3(this.lerpPos.x, this.lerpPos.y - 0.7, this.lerpPos.z);\r\n            Laya.Quaternion.lookAt(lookpos, this.curTarget.position, new Vector3(0, 1, 0), quaternion1);\r\n            quaternion1.invert(quaternion1);\r\n            Laya.Quaternion.slerp(this.camera.transform.rotation, quaternion1, 0.05, quaternion1);\r\n            this.camera.transform.rotation = quaternion1;\r\n        }\r\n    }\r\n    SetCameraPos() {\r\n        Vector3.subtract(this.curTarget.position, this.offest, this.curCameraPos);\r\n        Vector3.lerp(this.camera.transform.position, this.curCameraPos, 0.7, this.lerpPos);\r\n        this.camera.transform.position = new Vector3(this.lerpPos.x, this.camera.transform.position.y, this.camera.transform.position.z);\r\n    }\r\n    get GetCurCameraPos() {\r\n        Vector3.subtract(this.curTarget.position, this.offest, this.curCameraPos);\r\n        return this.curCameraPos;\r\n    }\r\n}\r\n//# sourceMappingURL=CameraManager.js.map",
  "references": [
    "C:/Users/admin/Desktop/runner/src/Scripts/Game/EventManager.ts",
    "C:/Users/admin/Desktop/runner/src/Scripts/Game/GameManager.ts",
    "C:/Users/admin/Desktop/runner/src/Scripts/Game/LevelManager.ts",
    "C:/Users/admin/Desktop/runner/src/GameUtils/GameUtils.ts"
  ],
  "map": "{\"version\":3,\"file\":\"CameraManager.js\",\"sourceRoot\":\"\",\"sources\":[\"../../../../src/Scripts/Game/CameraManager.ts\"],\"names\":[],\"mappings\":\"AAAA,IAAO,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;AAI9B,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,IAAI,CAAC,MAAM;IAGlD;QAEI,KAAK,EAAE,CAAC;QASL,WAAM,GAAG,KAAK,CAAC;QACtB,WAAM,GAAG,KAAK,CAAC;QA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