123456789 |
- {
- "code": "var Vector3 = Laya.Vector3;\r\nimport { CfgManager } from \"./CfgManager\";\r\nimport { PoolManager } from \"./PoolManager\";\r\nimport { Mathf } from \"../Util/Mathf\";\r\nexport default class TryDisPlayer {\r\n static get Instance() {\r\n return TryDisPlayer.instance || (TryDisPlayer.instance = new TryDisPlayer());\r\n }\r\n InitDis(par, trygunid) {\r\n if (!this._scene) {\r\n this._scene = new Laya.Scene3D();\r\n this._camera = new Laya.Camera();\r\n this._rotet = new Vector3(0, 0.01, 0);\r\n this._camera.enableHDR = false;\r\n this._scene.addChild(this._camera);\r\n this._light = new Laya.DirectionLight();\r\n this._light.transform.rotation = new Laya.Quaternion(0.3535534, 0.3535534, 0.1464466, -0.8535535);\r\n this._light.intensity = 0.45;\r\n this._scene.addChild(this._light);\r\n this._point = new Laya.Sprite3D();\r\n this._point.transform.position = new Vector3(0, -0.02, 0.2);\r\n this._point.transform.rotation = new Laya.Quaternion(-0.1144424, -0.6511531, -0.100222, 0.7435443);\r\n this._scene.addChild(this._point);\r\n this._camera.viewport = new Laya.Viewport(par.x, par.y, par.width, par.height);\r\n this._camera.farPlane = 0.01;\r\n this._camera.enableHDR = false;\r\n this._camera.clearFlag = 2;\r\n this._camera.fieldOfView = 55;\r\n this._camera.transform.position = new Vector3(0, 0, 0);\r\n this._camera.transform.rotation = new Laya.Quaternion(0, 1, 0, 0);\r\n }\r\n par.addChild(this._scene);\r\n this.SetGuns(trygunid);\r\n Laya.timer.frameLoop(2, this, this.Rot);\r\n }\r\n Rot() {\r\n this._point.transform.rotate(this._rotet, false);\r\n }\r\n SetGuns(id) {\r\n let t = CfgManager.Instance.GetThemeGun(id);\r\n if (!t)\r\n return;\r\n let name = t[\"prefab\"];\r\n this.gun = PoolManager.Instance.SetActiveObject(name);\r\n this._point.addChild(this.gun);\r\n this.gun.transform.localPosition = Mathf.VecZero;\r\n this.gun.transform.localRotationEuler = Mathf.VecZero;\r\n }\r\n Reset() {\r\n Laya.timer.clear(this, this.Rot);\r\n if (this.gun) {\r\n PoolManager.Instance.SetDisableObject(this.gun);\r\n this.gun = null;\r\n }\r\n if (this._scene) {\r\n this._scene.removeSelf();\r\n this._scene.destroy();\r\n this._scene = null;\r\n }\r\n }\r\n}\r\n",
- "references": [
- "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/CfgManager.ts",
- "D:/GitProject/GunGang/gungang_laya/gungang/src/GameLogic/PoolManager.ts",
- "D:/GitProject/GunGang/gungang_laya/gungang/src/Util/Mathf.ts"
- ]
- }
|