@goodfish/jarvy 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +1 -1
- package/README.zh-CN.md +2 -0
- package/dist/server/cli.js +280 -208
- package/dist/web/assets/figure-DBBkOPNl.js +1 -0
- package/dist/web/assets/index-C1Aq7FIn.js +505 -0
- package/dist/web/assets/index-CDOMm3pH.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +2 -2
- package/dist/web/assets/figure-BOkXKeYO.js +0 -1
- package/dist/web/assets/index-BYOxf981.js +0 -420
- package/dist/web/assets/index-CFv3-Mdq.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var j=Object.defineProperty;var F=(a,t,o)=>t in a?j(a,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[t]=o;var r=(a,t,o)=>F(a,typeof t!="symbol"?t+"":t,o);function X(a,t,o,e){const s=new a.Shape,i=-t/2,h=-o/2;return s.moveTo(i+e,h),s.lineTo(i+t-e,h),s.quadraticCurveTo(i+t,h,i+t,h+e),s.lineTo(i+t,h+o-e),s.quadraticCurveTo(i+t,h+o,i+t-e,h+o),s.lineTo(i+e,h+o),s.quadraticCurveTo(i,h+o,i,h+o-e),s.lineTo(i,h+e),s.quadraticCurveTo(i,h,i+e,h),s}function V(a){a.ColorManagement.enabled=!1;const t=new a.Scene,o=new a.PerspectiveCamera(35,1,.1,50);t.add(new a.HemisphereLight(16777215,7828845,.8*Math.PI));const e=new a.DirectionalLight(16777215,.85*Math.PI);e.position.set(-1.6,3.6,1.8),e.castShadow=!0,e.shadow.mapSize.set(1024,1024),e.shadow.bias=-5e-4,e.shadow.normalBias=.02,Object.assign(e.shadow.camera,{left:-2,right:2,top:2,bottom:-2,near:.5,far:10}),t.add(e);const s=new a.DirectionalLight(16777215,.35*Math.PI);s.position.set(2,1,4),t.add(s);const i=new a.Mesh(new a.PlaneGeometry(8,8),new a.ShadowMaterial({opacity:.32}));return i.rotation.x=-Math.PI/2,i.position.y=-.78,i.receiveShadow=!0,t.add(i),{scene:t,camera:o,ground:i}}function J(a,t){t.outputColorSpace=a.LinearSRGBColorSpace,t.shadowMap.enabled=!0,t.shadowMap.type=a.PCFShadowMap}function K(a,t,o=3.5){a.aspect=t,a.position.set(0,.5,Math.max(o,o*1.15/t*.9)),a.lookAt(0,-.02,0),a.updateProjectionMatrix()}class N{constructor(t,o){r(this,"root");r(this,"head");r(this,"eyes");r(this,"body");r(this,"parts");r(this,"paws");r(this,"paper");r(this,"mouth");r(this,"motion","static");r(this,"motionAt",0);r(this,"disposables",[]);r(this,"shown","normal");r(this,"yaw",.55);r(this,"pitch",0);r(this,"lookX",0);r(this,"lookY",0);r(this,"blinkAt",1500);r(this,"blinkStart",-1e9);r(this,"shakeAt",-1e9);r(this,"start",performance.now());const e=p=>(this.disposables.push(p),p);this.body=e(new t.MeshStandardMaterial({color:o,roughness:.55,metalness:0}));const s=e(new t.MeshBasicMaterial({color:2302495}));this.root=new t.Group,this.head=new t.Group,this.root.add(this.head);const i=e(new t.ExtrudeGeometry(X(t,1.2,.86,.2),{depth:.5,bevelEnabled:!0,bevelSize:.1,bevelThickness:.1,bevelSegments:6,curveSegments:14}));i.center();const h=new t.Mesh(i,this.body);h.castShadow=!0,h.receiveShadow=!0,this.head.add(h);const y=new t.Shape;y.moveTo(-.14,0),y.lineTo(.14,0),y.lineTo(0,.34),y.closePath();const u=e(new t.ExtrudeGeometry(y,{depth:.1,bevelEnabled:!0,bevelSize:.03,bevelThickness:.03,bevelSegments:3}));u.translate(0,0,-.05);for(const p of[-1,1]){const n=new t.Mesh(u,this.body);n.castShadow=!0,n.position.set(p*.42,.44,.04),n.rotation.z=-p*.2,this.head.add(n)}this.eyes=new t.Group,this.eyes.position.set(.12,.04,.352),this.head.add(this.eyes);const d=e(new t.ExtrudeGeometry(X(t,.08,.22,.04),{depth:.012,bevelEnabled:!1})),m=Math.PI*.85,b=.085,k=e(new t.TorusGeometry(b,.024,8,24,m)),g=e(new t.SphereGeometry(.024,10,8)),l=Array.from({length:91},(p,n)=>{const f=n/90,w=f*Math.PI*5,M=.012+f*.085;return new t.Vector3(Math.cos(w)*M,Math.sin(w)*M,0)}),z=e(new t.TubeGeometry(new t.CatmullRomCurve3(l),120,.012,6,!1));this.parts=[-.17,.17].map(p=>{const n=new t.Group;n.position.x=p,this.eyes.add(n);const f=new t.Mesh(d,s);n.add(f);const w=new t.Group,M=new t.Mesh(k,s);M.rotation.z=Math.PI/2-m/2,w.add(M);for(const A of[Math.PI/2-m/2,Math.PI/2+m/2]){const G=new t.Mesh(g,s);G.position.set(Math.cos(A)*b,Math.sin(A)*b,0),w.add(G)}w.position.set(0,-.04,.02),n.add(w);const v=new t.Mesh(z,s);return v.position.z=.014,n.add(v),{group:n,pill:f,arc:w,spiral:v}});const _=e(new t.SphereGeometry(1,24,16));this.paws=[-.42,.42].map(p=>{const n=new t.Mesh(_,this.body);return n.castShadow=!0,n.receiveShadow=!0,n.scale.set(.17,.1,.15),n.position.set(p,-.66,.22),this.root.add(n),n}),this.paper=new t.Mesh(e(new t.BoxGeometry(.62,.44,.012)),e(new t.MeshStandardMaterial({color:16184298,roughness:.9}))),this.paper.position.set(0,-.36,.62),this.paper.rotation.x=-.55,this.paper.castShadow=!0,this.paper.visible=!1,this.root.add(this.paper),this.mouth=new t.Mesh(e(new t.CircleGeometry(.07,20)),s),this.mouth.position.set(.12,-.2,.364),this.mouth.visible=!1,this.head.add(this.mouth),this.root.rotation.y=.55,this.show("normal")}setColor(t){this.body.color.setHex(t)}show(t){this.shown=t;for(const o of this.parts)o.pill.visible=t==="normal"||t==="sad"||t==="angry",o.arc.visible=t==="happy",o.spiral.visible=t==="dizzy"}pose(t){this.show(t),this.root.rotation.y=.55,this.head.rotation.set(t==="sad"?.1:t==="angry"?.06:0,0,0),this.head.position.y=0,this.eyes.position.set(.12,.04-(t==="sad"?.03:0)-(t==="angry"?.015:0),.352);const o=t==="sad"?.32:t==="angry"?-.38:0;this.parts.forEach((e,s)=>{e.group.scale.y=t==="angry"?.78:1,e.group.rotation.z=s?o:-o});for(const e of this.paws)e.position.y=-.66,e.scale.set(.17,.1,.15)}shake(t){this.shakeAt=t}frame(t,o){const e=(t-this.start)/1e3,s=o.motion,i=!!o.reduced;s!==this.motion&&(this.motion=s,this.motionAt=t);const h=(t-this.motionAt)/1e3,y=s==="yawn"?Math.sin(Math.PI*Math.min(1,h%3.2/1.8)):0,u=s==="stretch"?Math.sin(Math.PI*Math.min(1,h%3.6/1.8)):0,d=s==="sleep",m=s==="idle"&&this.shown!=="dizzy",b=!d&&this.shown==="dizzy",k=this.shown==="sad",g=this.shown==="angry",l=(c,S)=>i?0:Math.sin(e*c)*S,z=s==="work"||s==="think",p=(s==="turn"?.05:s==="ask"?.14:s==="read"?.55*.6:.55)+(m?o.lookX*.18:0)+(s==="busy"?l(9,.12):0)+(b?l(2.1,.1):0),n=(z?.14:m?o.lookY*.08:0)+(d?.16:0)+(k?.1:0)+(g?.06:0)+(s==="read"?.24+l(.7,.02):0)+(s==="groom"?.1:0)-.2*y-.14*u,f=(b?l(3.2,.07):0)+(s==="think"?l(1.3,.025):0)+(s==="busy"?l(9,.05):0)+(s==="ask"?.24+l(1.1,.03):0)+(s==="groom"?-.14:0)+(s==="turn"?l(2.4,.03):0);this.yaw+=(p-this.yaw)*.07,this.pitch+=(n-this.pitch)*.1,this.root.rotation.y=this.yaw,this.head.rotation.x=this.pitch,this.head.rotation.z+=(f-this.head.rotation.z)*.2;const w=i?0:s==="work"?Math.sin(e*(o.fast?20:14)):s==="think"?Math.sin(e*4.5)*.45:0,M=Math.max(0,w),v=Math.max(0,-w),A=b?0:m?o.lookX*.6:s==="work"?i?0:M>v?-.6:.6:s==="think"?l(.9,.5):s==="busy"?l(9,.5):s==="read"?i?0:h*.8%1*1.2-.6:0,G=b?0:m?-o.lookY*.7:z||s==="read"?-1:d?-.3:0;this.lookX+=(A-this.lookX)*.2,this.lookY+=(G-this.lookY)*.15;const q=Math.max(-.2,Math.min(.2,(p-this.yaw)*.6));this.eyes.position.x=.12+q+this.lookX*.06,this.eyes.position.y=.04+this.lookY*.09-(k?.03:0)-(g?.015:0);const L=!d&&(this.shown==="normal"||k||g);s!=="static"&&L&&t-this.start>this.blinkAt&&t-this.blinkStart>400&&(this.blinkStart=t,this.blinkAt=t-this.start+2200+Math.random()*3200),o.mood!==this.shown&&t-this.blinkStart>400&&(this.blinkStart=t);const x=(t-this.blinkStart)/160;o.mood!==this.shown&&x>=.5&&this.show(o.mood);for(const c of this.parts)c.pill.visible=d||this.shown==="normal"||k||g,c.arc.visible=!d&&this.shown==="happy",c.spiral.visible=!d&&this.shown==="dizzy";const W=Math.max(y,u*.9,s==="groom"?.9:0),D=(d?.1:x>=0&&x<=1?1-.92*Math.sin(Math.PI*x):1)*(1-.88*W),B=d?0:k?.32:g?-.38:0;this.parts.forEach((c,S)=>{c.group.scale.y=D*(g&&!d?.78:1),c.group.rotation.z+=((S?B:-B)-c.group.rotation.z)*.15,i||(c.spiral.rotation.z+=.14)}),this.paws.forEach((c,S)=>{const P=S?v:M,I=S?1:-1,C=s==="read"?[I*.3,-.44+l(.7,.01),.6]:s==="stretch"?[I*(.42+.2*u),-.66+.62*u,.22-.1*u]:s==="groom"&&S?[.2,-.2+l(7,.035),.5]:s==="turn"&&S?[.4,-.52+l(3,.05),.32]:[I*.42,-.66-.06*P,.22];c.position.x+=(C[0]-c.position.x)*.2,c.position.y+=(C[1]-c.position.y)*.2,c.position.z+=(C[2]-c.position.z)*.2,c.scale.set(.17*(1+.25*P),.1*(1-.3*P),.15*(1+.25*P))}),this.paper.visible=s==="read",this.mouth.visible=y>.05,this.mouth.scale.set(.8+.3*y,.2+1.3*y,1),this.root.scale.y=1+.05*u,this.head.position.y=(s==="static"?0:d?l(1.2,.02)-.02:l(2,.01))-.03*(M+v)+.04*y+.06*u;const Y=(t-this.shakeAt)/600;this.root.position.x=!i&&Y>=0&&Y<1?Math.sin(Y*Math.PI*6)*.06*(1-Y):0}dispose(){for(const t of this.disposables)t.dispose()}}export{N as CatFigure,J as configureRenderer,V as createStage,K as frameCamera};
|