{ "code": "var Vector3 = Laya.Vector3;\r\nimport { SceneManager } from \"./SceneManager\";\r\nexport class CameraManager extends Laya.Script3D {\r\n constructor() {\r\n super();\r\n this.follow = false;\r\n this.offest = new Vector3();\r\n this.followrate = 0.25;\r\n this.curcamerapos = new Vector3();\r\n this.curstarpos = new Vector3();\r\n CameraManager.instance = this;\r\n }\r\n static get Instance() {\r\n return CameraManager.instance;\r\n }\r\n SetFollow(_target) {\r\n if (!this.m_cameranode) {\r\n this.m_cameranode = SceneManager.maincamera;\r\n }\r\n this.follow = true;\r\n this.FollowTarget = _target;\r\n Vector3.subtract(_target.transform.position, this.m_cameranode.transform.position, this.offest);\r\n }\r\n SetOffest(_targetpos, _target) {\r\n this.FollowTarget = _target;\r\n Vector3.subtract(_target.transform.position, _targetpos, this.offest);\r\n }\r\n ResetTarget(_target) {\r\n this.FollowTarget = _target;\r\n this.follow = true;\r\n }\r\n StopFollow() {\r\n this.follow = false;\r\n this.FollowTarget = null;\r\n }\r\n onUpdate() {\r\n if (this.follow && this.FollowTarget) {\r\n Vector3.subtract(this.FollowTarget.transform.position, this.offest, this.curcamerapos);\r\n var curposz = this.curcamerapos.z;\r\n Vector3.lerp(SceneManager.maincamera.transform.position, this.curcamerapos, this.followrate, this.curcamerapos);\r\n this.curcamerapos = new Vector3(this.curcamerapos.x, this.curcamerapos.y, curposz);\r\n SceneManager.maincamera.transform.position = new Vector3(this.curcamerapos.x, this.curcamerapos.y, this.curcamerapos.z);\r\n }\r\n }\r\n}\r\n", "references": [ "D:/Work/samurai2-laya/laya/samuraiflash-tt/src/Main/SceneManager.ts" ] }