mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-03-14 18:00:50 +00:00
1 line
No EOL
4 KiB
JavaScript
1 line
No EOL
4 KiB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,66069,e=>{"use strict";var r=e.i(932),t=e.i(71645),n=e.i(90072),c=e.i(71753),u=e.i(15080),o=e.i(79123),i=e.i(66093);let l=Math.PI/2-.01;function a(){let e,a,h,d,f,v,E,y,x,g,S,p=(0,r.c)(27),{speedMultiplier:M,touchMode:T,invertDrag:q,invertJoystick:b}=(0,o.useControls)(),L=(0,u.useThree)(m),_=(0,u.useThree)(s),{moveState:k,lookState:F}=(0,i.useJoystick)();p[0]===Symbol.for("react.memo_cache_sentinel")?(e=new n.Euler(0,0,0,"YXZ"),p[0]=e):e=p[0];let R=(0,t.useRef)(e),X=(0,t.useRef)(null);p[1]===Symbol.for("react.memo_cache_sentinel")?(a={x:0,y:0},p[1]=a):a=p[1];let Y=(0,t.useRef)(a);p[2]!==q?(h=()=>q,p[2]=q,p[3]=h):h=p[3];let V=(0,t.useEffectEvent)(h);p[4]===Symbol.for("react.memo_cache_sentinel")?(d=new n.Vector3,p[4]=d):d=p[4];let Z=(0,t.useRef)(d);p[5]===Symbol.for("react.memo_cache_sentinel")?(f=new n.Vector3,p[5]=f):f=p[5];let w=(0,t.useRef)(f);p[6]===Symbol.for("react.memo_cache_sentinel")?(v=new n.Vector3,p[6]=v):v=p[6];let z=(0,t.useRef)(v);return p[7]!==L.quaternion?(E=()=>{R.current.setFromQuaternion(L.quaternion,"YXZ")},p[7]=L.quaternion,p[8]=E):E=p[8],p[9]!==L?(y=[L],p[9]=L,p[10]=y):y=p[10],(0,t.useEffect)(E,y),p[11]!==L.quaternion||p[12]!==V||p[13]!==_.domElement||p[14]!==T?(x=()=>{if("moveLookStick"!==T)return;let e=_.domElement,r=e=>{if(null===X.current)for(;0<e.changedTouches.length;){let r=e.changedTouches[0];X.current=r.identifier,Y.current={x:r.clientX,y:r.clientY};break}},t=e=>{if(null!==X.current)for(let r=0;r<e.changedTouches.length;r++){let t=e.changedTouches[r];if(t.identifier===X.current){let e=t.clientX-Y.current.x,r=t.clientY-Y.current.y;Y.current={x:t.clientX,y:t.clientY};let n=V()?-1:1;R.current.setFromQuaternion(L.quaternion,"YXZ"),R.current.y=R.current.y+n*e*.004,R.current.x=R.current.x+n*r*.004,R.current.x=Math.max(-l,Math.min(l,R.current.x)),L.quaternion.setFromEuler(R.current);break}}},n=e=>{for(let r=0;r<e.changedTouches.length;r++)if(e.changedTouches[r].identifier===X.current){X.current=null;break}};return e.addEventListener("touchstart",r,{passive:!0}),e.addEventListener("touchmove",t,{passive:!0}),e.addEventListener("touchend",n,{passive:!0}),e.addEventListener("touchcancel",n,{passive:!0}),()=>{e.removeEventListener("touchstart",r),e.removeEventListener("touchmove",t),e.removeEventListener("touchend",n),e.removeEventListener("touchcancel",n),X.current=null}},p[11]=L.quaternion,p[12]=V,p[13]=_.domElement,p[14]=T,p[15]=x):x=p[15],p[16]!==L||p[17]!==_.domElement||p[18]!==T?(g=[L,_.domElement,T],p[16]=L,p[17]=_.domElement,p[18]=T,p[19]=g):g=p[19],(0,t.useEffect)(x,g),p[20]!==L||p[21]!==b||p[22]!==F.current||p[23]!==k.current||p[24]!==M||p[25]!==T?(S=(e,r)=>{let{force:t,angle:n}=k.current,{force:c,angle:u}=F.current;if("dualStick"===T){if(c>.15){let e=(c-.15)/.85,t=Math.cos(u),n=Math.sin(u),o=b?-1:1;R.current.setFromQuaternion(L.quaternion,"YXZ"),R.current.y=R.current.y-o*t*e*2.5*r,R.current.x=R.current.x+o*n*e*2.5*r,R.current.x=Math.max(-l,Math.min(l,R.current.x)),L.quaternion.setFromEuler(R.current)}if(t>.08){let e=80*M*((t-.08)/.92),c=Math.cos(n),u=Math.sin(n);L.getWorldDirection(Z.current),Z.current.normalize(),w.current.crossVectors(L.up,Z.current).normalize(),z.current.set(0,0,0).addScaledVector(Z.current,u).addScaledVector(w.current,-c),z.current.lengthSq()>0&&(z.current.normalize().multiplyScalar(e*r),L.position.add(z.current))}}else if("moveLookStick"===T&&t>0){let e=80*M*.5;if(L.getWorldDirection(Z.current),Z.current.normalize(),z.current.copy(Z.current).multiplyScalar(e*r),L.position.add(z.current),t>=.15){let e=Math.cos(n),c=Math.sin(n),u=(t-.15)/.85,o=b?-1:1;R.current.setFromQuaternion(L.quaternion,"YXZ"),R.current.y=R.current.y-o*e*u*1.25*r,R.current.x=R.current.x+o*c*u*1.25*r,R.current.x=Math.max(-l,Math.min(l,R.current.x)),L.quaternion.setFromEuler(R.current)}}},p[20]=L,p[21]=b,p[22]=F.current,p[23]=k.current,p[24]=M,p[25]=T,p[26]=S):S=p[26],(0,c.useFrame)(S),null}function s(e){return e.gl}function m(e){return e.camera}e.s(["TouchHandler",()=>a])}]); |