{
  "code": "var Vector3 = Laya.Vector3;\r\nimport { ScenceManager } from \"./ScenceManager\";\r\nimport { ColliderLay } from \"./Runner\";\r\nexport class Rigbody extends Laya.Script3D {\r\n    constructor() {\r\n        super(...arguments);\r\n        this.m_life = 1;\r\n        this.m_time = 0;\r\n        this.m_resistance = 0.03;\r\n        this.OnLand = true;\r\n        this.hit = new Laya.HitResult();\r\n        this.offestY = 0;\r\n        this.g = 1;\r\n        this.curdir = new Vector3();\r\n        this.curPos = new Vector3();\r\n    }\r\n    onAwake() {\r\n        this.m_sprite = this.owner;\r\n        Laya.timer.once(this.m_life * 1000, this, this.OnEnd);\r\n        Laya.timer.frameLoop(1, this, this.Update);\r\n    }\r\n    OnEnd() {\r\n        Laya.timer.clearAll(this);\r\n        this.destroy();\r\n    }\r\n    CheckPlaneCollider() {\r\n        var startpoint = new Vector3(this.m_sprite.transform.position.x, this.m_sprite.transform.position.y, this.m_sprite.transform.position.z);\r\n        var dir = new Vector3(0, -1, 0);\r\n        var ray = new Laya.Ray(startpoint, dir);\r\n        if (ScenceManager.Instance.GameScence.physicsSimulation.rayCast(ray, this.hit, 0.5)) {\r\n            if (this.hit.collider.collisionGroup != ColliderLay.Plane)\r\n                return;\r\n            var dis = this.m_sprite.transform.position.y - this.hit.point.y;\r\n            if (this.OnLand) {\r\n                if (dis > 0.15) {\r\n                    this.OnLand = false;\r\n                    return;\r\n                }\r\n                else {\r\n                    this.m_sprite.transform.position = new Vector3(this.m_sprite.transform.position.x, this.hit.point.y + 0.1, this.m_sprite.transform.position.z);\r\n                }\r\n            }\r\n            else {\r\n                if (dis < 0.01) {\r\n                    this.OnLand = true;\r\n                    this.OnPlane();\r\n                }\r\n            }\r\n        }\r\n        else {\r\n            this.OnLand = false;\r\n        }\r\n    }\r\n    OnPlane() {\r\n    }\r\n    gravity() {\r\n        this.offestY -= this.g * this.m_time * this.m_time;\r\n    }\r\n    AddVelocity(_dir, _speed) {\r\n        Vector3.normalize(_dir, this.curdir);\r\n        Vector3.scale(this.curdir, _speed, this.curdir);\r\n        Laya.timer.frameLoop(1, this, this.Move);\r\n    }\r\n    Update() {\r\n        this.m_time += 0.012;\r\n        this.gravity();\r\n        this.CheckPlaneCollider();\r\n    }\r\n    Move() {\r\n        var mpos = this.m_sprite.transform.position;\r\n        Vector3.add(mpos, this.curdir, this.curPos);\r\n        if (this.OnLand) {\r\n            this.curPos = new Vector3(this.curPos.x, this.m_sprite.transform.position.y, this.curPos.z);\r\n        }\r\n        else {\r\n            Vector3.add(this.curPos, new Vector3(0, this.offestY, 0), this.curPos);\r\n        }\r\n        this.m_sprite.transform.position = this.curPos;\r\n        Vector3.lerp(this.curdir, new Vector3(0, 0, 0), this.m_resistance, this.curdir);\r\n        if (Vector3.scalarLength(this.curdir) < 0.01) {\r\n            Laya.timer.clear(this, this.Move);\r\n        }\r\n    }\r\n}\r\n//# sourceMappingURL=Rigbody.js.map",
  "references": [
    "C:/Users/admin/Desktop/runner/src/Scripts/Game/ScenceManager.ts",
    "C:/Users/admin/Desktop/runner/src/Scripts/Game/Runner.ts"
  ],
  "map": "{\"version\":3,\"file\":\"Rigbody.js\",\"sourceRoot\":\"\",\"sources\":[\"../../../../src/Scripts/Game/Rigbody.ts\"],\"names\":[],\"mappings\":\"AACA,IAAO,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,OAAO,OAAQ,SAAQ,IAAI,CAAC,QAAQ;IAA1C;;QAGI,WAAM,GAAU,CAAC,CAAC;QAClB,WAAM,GAAU,CAAC,CAAC;QAClB,iBAAY,GAAG,IAAI,CAAC;QAcpB,WAAM,GAAG,IAAI,CAAC;QACd,QAAG,GAAkB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QA0C1C,YAAO,GAAG,CAAC,CAAC;QACZ,MAAC,GAAG,CAAC,CAAC;QAUN,W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