ocearo-ui
Version:
Ocean Robot UI: Sailing made smarter
1 lines • 8.44 kB
JavaScript
;(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[188],{95723:function(e,t,n){var r=n(57437),a=n(2265),o=n(40718),i=n.n(o),s=n(53082),l=n(72079),h=n(45476);let M={TRUE_WIND:1,APP_WIND:1},T=e=>{let{position:t=[0,0,0],rotation:n=[0,0,0],speed:a,color:o="#ffffff",fontSize:i=.5,textPosition:s=[0,.8,0],arrowSize:M=1}=e;return(0,r.jsxs)("group",{position:t,rotation:n,children:[(0,r.jsx)(h.x,{characters:".0123456789",color:o,fontSize:i*M,position:s,font:"fonts/Roboto-Bold.ttf",anchorX:"center",anchorY:"middle",children:a.toFixed(1)}),(0,r.jsxs)("mesh",{children:[(0,r.jsx)("shapeGeometry",{args:[new l.bnF([new l.FM8(0,0),new l.FM8(.5*M*Math.cos(5*Math.PI/6),.5*M*Math.sin(5*Math.PI/6)),new l.FM8(0,-.577*M),new l.FM8(-.5*M*Math.cos(5*Math.PI/6),.5*M*Math.sin(5*Math.PI/6)),new l.FM8(0,0)])]}),(0,r.jsx)("meshStandardMaterial",{color:o,side:l.ehD})]})]})};T.propTypes={position:i().oneOfType([i().instanceOf(l.Pa4),i().arrayOf(i().number)]).isRequired,rotation:i().arrayOf(i().number).isRequired,speed:i().number.isRequired,color:i().oneOfType([i().string,i().number]).isRequired,fontSize:i().number,textPosition:i().arrayOf(i().number),arrowSize:i().number};let u=e=>{let{outerRadius:t}=e,{getSignalKValue:n}=(0,s.yC)(),o=Math.PI/2-n("environment.wind.angleTrueGround")||0,i=(0,s.HQ)(n("environment.wind.speedOverGround"))||0,h=Math.PI/2-n("environment.wind.angleApparent")||0,u=(0,s.HQ)(n("environment.wind.speedApparent"))||0,d=(0,a.useMemo)(()=>new l.Pa4((t+.7)*Math.cos(o),0,-(t+.7)*Math.sin(o)),[t,o]),c=(0,a.useMemo)(()=>new l.Pa4((t+.7)*Math.cos(h),0,-(t+.7)*Math.sin(h)),[t,h]);return(0,r.jsxs)("group",{children:[i>0&&(0,r.jsx)(T,{position:d,rotation:[-Math.PI/2,0,-(Math.PI/2-o)],speed:i,color:"#0000FF",fontSize:M.TRUE_WIND}),u>0&&(0,r.jsx)(T,{position:c,rotation:[-Math.PI/2,0,-(Math.PI/2-h)],speed:u,color:s.gK,fontSize:M.APP_WIND})]})};u.propTypes={outerRadius:i().number.isRequired},t.Z=u},97188:function(e,t,n){n.r(t),n.d(t,{default:function(){return m}});var r=n(57437),a=n(2265),o=n(68328),i=n(44725),s=n(85903),l=n(5550),h=n(11909),M=n(53082),T=n(95723),u=n(72079);let d={MOBILE_TEMPLATE:{COLOR:"yellow",WIDTH_FACTOR:.8,LENGTH_FACTOR:2.5,MAX_LENGTH_MULTIPLIER:3.5,CURVATURE_SENSITIVITY:{RUDDER:1.5,WIND:.25,CURRENT:.3,LEEWAY:.15,DRIFT:.1}},NEUTRAL_TEMPLATE:{COLOR:"blue",WIDTH_FACTOR:.7,LENGTH_FACTOR:.9},ANTICOLLISION_TEMPLATE:{COLOR:"red",WIDTH_FACTOR:1.5,LENGTH_FACTOR:.8}};var c=e=>{let{rudderAngle:t=0,sog:n=5,boatWidth:o=2,windSpeed:i=0,windDirection:s=0,currentSpeed:l=0,currentDirection:h=0,leewayAngle:M=0,driftFactor:T=0,maxCurvePoints:c=50}=e,f=(0,a.useRef)(),E=(0,a.useRef)(),I=(0,a.useRef)(),p=(0,a.useCallback)(()=>{let e=e=>u.M8C.degToRad(e),t=e(s),n=e(M),r=Math.cos(t+n)*i*d.MOBILE_TEMPLATE.CURVATURE_SENSITIVITY.WIND,a=Math.sin(t+n)*i*d.MOBILE_TEMPLATE.CURVATURE_SENSITIVITY.WIND,o=e(h),c=Math.cos(o)*l*d.MOBILE_TEMPLATE.CURVATURE_SENSITIVITY.CURRENT,f=Math.sin(o)*l*d.MOBILE_TEMPLATE.CURVATURE_SENSITIVITY.CURRENT;return{x:(r+c)*(1+T*d.MOBILE_TEMPLATE.CURVATURE_SENSITIVITY.DRIFT),z:(a+f)*(1+T*d.MOBILE_TEMPLATE.CURVATURE_SENSITIVITY.DRIFT)}},[i,s,l,h,M,T]),R=(0,a.useCallback)(()=>{let e=o*d.MOBILE_TEMPLATE.MAX_LENGTH_MULTIPLIER,n=Math.min(2*o*d.MOBILE_TEMPLATE.LENGTH_FACTOR,e),r=[],a=1.5*p().x;if(.1>Math.abs(t)){let e=.5*a,t=Math.max(o/Math.tan(u.M8C.degToRad(5+Math.abs(e))),.5*o),i=n/t,s=new u.FM8(e>0?t:-t,0),l=e>0?Math.PI:0;for(let n=0;n<=c;n++){let a=l+n/c*(e>0?i:-i),o=s.x+t*Math.cos(a),h=s.y+t*Math.sin(a);r.push(new u.Pa4(o,0,h))}}else{let e=u.M8C.clamp(1.2*Math.abs(t)+a,0,85),i=o/Math.tan(u.M8C.degToRad(e*d.MOBILE_TEMPLATE.CURVATURE_SENSITIVITY.RUDDER)),s=u.M8C.clamp(n/i,0,1.25*Math.PI);if(t>0){let e=new u.FM8(i,0),t=Math.PI;for(let n=0;n<=c;n++){let a=n/c,o=u.M8C.lerp(t,t+s,a),l=e.x+i*Math.cos(o),h=e.y+i*Math.sin(o);r.push(new u.Pa4(l,0,h))}}else{let e=new u.FM8(-i,0);for(let t=0;t<=c;t++){let n=t/c,a=u.M8C.lerp(0,0-s,n),o=e.x+i*Math.cos(a),l=e.y+i*Math.sin(a);r.push(new u.Pa4(o,0,l))}}}let i=r.map((e,t)=>{let n;(n=0===t?r[1].clone().sub(e):e.clone().sub(r[t-1])).normalize();let a=new u.Pa4(-n.z,0,n.x),i=o/1.8;return{left:e.clone().add(a.multiplyScalar(i)),right:e.clone().sub(a.multiplyScalar(i))}});return[...i.map(e=>e.left),i[i.length-1].right,...i.reverse().map(e=>e.right)]},[o,t,c,p]),m=(0,a.useCallback)(e=>{if("MOBILE_TEMPLATE"===e)return R();let t=d[e],n=2*o*t.LENGTH_FACTOR,r=o*t.WIDTH_FACTOR,a=[],i=Math.floor(c/4);for(let e=0;e<=i;e++){let t=e/i;a.push(new u.Pa4(-r/2,0,-n*t))}a.push(new u.Pa4(r/2,0,-n));for(let e=i;e>=0;e--){let t=e/i;a.push(new u.Pa4(r/2,0,-n*t))}return a},[o,c,R]);return(0,a.useEffect)(()=>{f.current&&E.current&&I.current&&(f.current.geometry.setFromPoints(m("MOBILE_TEMPLATE")),E.current.geometry.setFromPoints(m("NEUTRAL_TEMPLATE")),I.current.geometry.setFromPoints(m("ANTICOLLISION_TEMPLATE")))},[m]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("line",{ref:f,children:[(0,r.jsx)("bufferGeometry",{}),(0,r.jsx)("lineBasicMaterial",{color:d.MOBILE_TEMPLATE.COLOR,linewidth:2})]}),(0,r.jsxs)("line",{ref:E,children:[(0,r.jsx)("bufferGeometry",{}),(0,r.jsx)("lineBasicMaterial",{color:d.NEUTRAL_TEMPLATE.COLOR,linewidth:2})]}),(0,r.jsxs)("line",{ref:I,children:[(0,r.jsx)("bufferGeometry",{}),(0,r.jsx)("lineBasicMaterial",{color:d.ANTICOLLISION_TEMPLATE.COLOR,linewidth:2})]})]})},f=n(40718),E=n.n(f),I=n(45476);let p=e=>{let{position:t,rotation:n,speed:a,color:o="#ffffff",fontSize:i=.5,textPosition:s=[0,.8,0],arrowSize:l=1}=e;return(0,r.jsxs)("group",{position:t,rotation:n,children:[(0,r.jsx)(I.x,{characters:"0123456789.",color:o,fontSize:i*l,position:s,font:"fonts/Roboto-Bold.ttf",anchorX:"center",anchorY:"middle",children:a.toFixed(1)}),(0,r.jsxs)("mesh",{children:[(0,r.jsx)("shapeGeometry",{args:[new u.bnF([new u.FM8(0,0),new u.FM8(.5*l*Math.cos(5*Math.PI/6),.5*l*Math.sin(5*Math.PI/6)),new u.FM8(0,-.577*l),new u.FM8(-.5*l*Math.cos(5*Math.PI/6),.5*l*Math.sin(5*Math.PI/6)),new u.FM8(0,0)])]}),(0,r.jsx)("meshStandardMaterial",{color:o,side:u.ehD})]})]})};p.propTypes={position:E().arrayOf(E().number),rotation:E().arrayOf(E().number),speed:E().number.isRequired,color:E().string,fontSize:E().number,textPosition:E().arrayOf(E().number),arrowSize:E().number},p.defaultProps={position:[0,0,0],rotation:[0,0,0],color:"#ffffff",fontSize:.5,textPosition:[0,.8,0],arrowSize:1};let R=e=>{let{outerRadius:t}=e,{getSignalKValue:n}=(0,M.yC)(),o=n("environment.current")||{setTrue:0,drift:0},i=(0,a.useMemo)(()=>{let e=o.setTrue||0;return[(t+.7)*Math.cos(e),0,-(t+.7)*Math.sin(e)]},[t,o.setTrue]);return!o.drift||o.drift<=0?null:(0,r.jsx)("group",{children:(0,r.jsx)(p,{position:i,rotation:[-Math.PI/2,0,-(Math.PI/2-(o.setTrue||0))],speed:o.drift,color:M.FV,arrowSize:1.2})})};R.propTypes={outerRadius:E().number.isRequired};var m=e=>{let{onUpdateInfoPanel:t}=e,n=(0,a.useRef)(),{getSignalKValue:u}=(0,M.yC)(),d=u("steering.rudderAngle")||0,f=u("navigation.speedOverGround")||0,E=u("environment.wind.angleApparent")||0,I=(0,M.HQ)(u("environment.wind.speedApparent"))||0,p=u("environment.current")||{setTrue:0,drift:0};return(0,r.jsxs)(a.Suspense,{fallback:(0,r.jsx)(o.V,{center:!0,children:"Loading..."}),children:[(0,r.jsx)(i.c,{makeDefault:!0,fov:60,near:1,far:1e3,position:[0,1,10]}),(0,r.jsx)(s.z,{enableZoom:!0,enableRotate:!0,maxPolarAngle:Math.PI/2,minPolarAngle:Math.PI/4}),(0,r.jsx)(l.qA,{files:"./assets/ocearo_env.hdr",background:!1,intensity:.8}),(0,r.jsx)("ambientLight",{intensity:.6}),(0,r.jsx)("spotLight",{position:[15,30,20],intensity:1.8,angle:Math.PI/6,penumbra:.5,castShadow:!0,"shadow-mapSize-width":1024,"shadow-mapSize-height":1024,"shadow-camera-near":.5,"shadow-camera-far":50,"shadow-bias":-.0001}),(0,r.jsx)("directionalLight",{position:[-10,20,10],intensity:1.5,castShadow:!0,"shadow-mapSize-width":1024,"shadow-mapSize-height":1024,"shadow-camera-near":.5,"shadow-camera-far":50,"shadow-bias":-.0001,color:"#ffd1a6"}),(0,r.jsx)("pointLight",{position:[-10,10,-10],intensity:.7}),(0,r.jsxs)("group",{position:[0,-3,0],children:[(0,r.jsx)(h.Z,{position:[0,0,.7],scale:[.5,.5,.5],ref:n,showSail:!1,onUpdateInfoPanel:t}),(0,r.jsx)(T.Z,{outerRadius:5}),(0,r.jsx)(R,{outerRadius:5}),(0,r.jsx)("group",{position:[0,0,-5],children:(0,r.jsx)(c,{rudderAngle:d,sog:f,windSpeed:I,windDirection:E,currentSpeed:p.drift,currentDirection:p.setTrue,boatWidth:2,leewayAngle:Math.min(Math.sin(Math.abs(E*Math.PI/180))*I*.02,10),driftFactor:f<.1?0:Math.min(p.drift/f,1),maxCurvePoints:100})})]})]})}}}]);