import{__awaiter as t,__extends as n,__generator as i}from"tslib";import{throttle as o}from"lodash";import{MOUSE as e}from"three";import{EventEmitter as c}from"events";import*as r from"@msign/angularis";var u=function(c){function u(t,n){var i=c.call(this)||this;return i.t=!1,i.i=!1,i.o=new Map,i.u=!1,i.s=function(t){console.log("光标锁定仅能由用户鼠标操作触发, 请点击一次屏幕."),document.addEventListener("click",i.h.bind(i),{once:!0}),document.addEventListener("pointerlockchange",i.m,{once:!0})},i.m=function(t){document.addEventListener("pointerlockchange",i.p,{once:!0})},i.p=function(t){i.l("exit",t),i.v()},i.k=function(t){i.u=!i.u,i.u||(i.l("exit",t),i.v())},i.g=function(t){i.o.set(t.key,!0),i.i||i.q()},i.M=function(t){i.o.set(t.key,!1)},i.q=function(){var t=i,n=t.o,o=t.A,e=o.j,c=(e.position,e.direction),u=e.F,s=1;n.get("w")||n.get("a")||n.get("s")||n.get("d")||n.get("q")||n.get("e")?(requestAnimationFrame(i.q),i.i=!0):i.i=!1;var h=r.O.ZERO.clone(),f=r.O.B(c,u,r.O.ZERO.clone());if(n.get("w")){var a=o.canvas,m=new r.C(a.width/2,a.height/2),d=o.G.D(m);if(r.O.add(h,c,h),d){var p=o.j.position;s=r.O.H(d,p)/30}}n.get("s")&&r.O.I(h,c,h),n.get("a")&&r.O.I(h,f,h),n.get("d")&&r.O.add(h,f,h),n.get("q")&&r.O.I(h,u,h),n.get("e")&&r.O.add(h,u,h),e.move(h,s)},i.J=function(t){switch(t.button){case e.K:case e.L:case e.N:}},i.P=function(t){},i.R=o((function(t){if(document.pointerLockElement){var n=t.S,o=t.T,e=i.A.j;e.U(n*Math.PI/1440),e.V(o*Math.PI/1440),r.O.normalize(e.position,e.F)}}),10),i.W=function(t){},i.A=n,i.X=t,i}return n(u,c),u.prototype.h=function(){return t(this,void 0,void 0,(function(){var t,n;return i(this,(function(i){t=this.A,n=t.Y;try{n.requestPointerLock()}catch(t){}return[2]}))}))},u.prototype.Z=function(){},u.prototype.$=function(){this.A;document.addEventListener("pointerlockerror",this.s),document.addEventListener("pointerlockchange",this.k),document.addEventListener("pointermove",this.R),document.addEventListener("keydown",this.g),document.addEventListener("keyup",this.M)},u.prototype.v=function(){this.A;document.removeEventListener("pointerlockerror",this.s),document.removeEventListener("pointerlockchange",this.k),document.removeEventListener("pointermove",this.R),document.removeEventListener("keydown",this.g),document.removeEventListener("keyup",this.M)},Object.defineProperty(u.prototype,"_",{get:function(){return this.t},set:function(t){this.X;t!==this.t&&(t?(this.h(),this.$()):(this.Z(),this.v()),this.t=t)},tt:!0,nt:!0}),u}(c);export default u;