@goodfish/jarvy 0.3.0 → 0.5.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 +36 -0
- package/README.md +7 -3
- package/README.zh-CN.md +7 -3
- package/dist/server/cli.js +974 -130
- package/dist/web/assets/figure-DQGUDG-4.js +1 -0
- package/dist/web/assets/index-DoVuF8GU.js +534 -0
- package/dist/web/assets/index-Dsjq2IH9.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/figure-DBBkOPNl.js +0 -1
- package/dist/web/assets/index-C1Aq7FIn.js +0 -505
- package/dist/web/assets/index-CDOMm3pH.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var $=Object.defineProperty;var T=(n,t,e)=>t in n?$(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var h=(n,t,e)=>T(n,typeof t!="symbol"?t+"":t,e);const N=.22999999999999998,R=.76,H=.22,E=1.1,tt=.02,st=.3;class ot{constructor(t){h(this,"root");h(this,"spin");h(this,"disposables",[]);const e=a=>(this.disposables.push(a),a);this.root=new t.Group,this.root.rotation.x=H,this.root.visible=!1,this.spin=new t.Group,this.root.add(this.spin);const o=e(new t.CylinderGeometry(.2*1.12,.2,N,80,1,!0)),s=o.attributes.position;for(let a=0;a<s.count;a++)if(s.getY(a)>0){const y=(Math.atan2(s.getX(a),s.getZ(a))/(2*Math.PI)*5%1+1)%1;s.setY(a,-N/2+.08+.15*(1-Math.abs(y-.5)*2))}o.computeVertexNormals();const i=e(new t.MeshStandardMaterial({color:15906864,roughness:.35,metalness:.25,side:t.DoubleSide})),c=new t.Mesh(o,i);c.castShadow=!0,this.spin.add(c);const w=e(new t.MeshStandardMaterial({color:16774876,roughness:.3})),u=e(new t.SphereGeometry(.038,12,10)),p=[14697818,4029408].map(a=>e(new t.MeshStandardMaterial({color:a,roughness:.25}))),g=e(new t.SphereGeometry(.036,12,10));for(let a=0;a<5;a++){const y=(a+.5)/5*2*Math.PI,M=new t.Mesh(u,w);M.castShadow=!0,M.position.set(Math.sin(y)*.2*1.12,N/2,Math.cos(y)*.2*1.12),this.spin.add(M);const l=a/5*2*Math.PI,f=new t.Mesh(g,p[a%2]);f.scale.z=.5,f.rotation.y=l,f.position.set(Math.sin(l)*.2*1.04,-N/2+.08/2,Math.cos(l)*.2*1.04),this.spin.add(f)}}place(t,e,o,s){this.root.position.set(0,R+Math.min(t,.02)+(s?0:Math.sin(o*1.6)*tt),0),this.root.rotation.y=-e,this.spin.rotation.y=s?st:o*E}}const A=.55,x=.12,et=.6;function V(n,t,e,o){const s=new n.Shape,i=-t/2,c=-e/2;return s.moveTo(i+o,c),s.lineTo(i+t-o,c),s.quadraticCurveTo(i+t,c,i+t,c+o),s.lineTo(i+t,c+e-o),s.quadraticCurveTo(i+t,c+e,i+t-o,c+e),s.lineTo(i+o,c+e),s.quadraticCurveTo(i,c+e,i,c+e-o),s.lineTo(i,c+o),s.quadraticCurveTo(i,c,i+o,c),s}function at(n){n.ColorManagement.enabled=!1;const t=new n.Scene,e=new n.PerspectiveCamera(35,1,.1,50);t.add(new n.HemisphereLight(16777215,7828845,.8*Math.PI));const o=new n.DirectionalLight(16777215,.85*Math.PI);o.position.set(-1.6,3.6,1.8),o.castShadow=!0,o.shadow.mapSize.set(1024,1024),o.shadow.bias=-5e-4,o.shadow.normalBias=.02,Object.assign(o.shadow.camera,{left:-2,right:2,top:2,bottom:-2,near:.5,far:10}),t.add(o);const s=new n.DirectionalLight(16777215,.35*Math.PI);s.position.set(2,1,4),t.add(s);const i=new n.Mesh(new n.PlaneGeometry(8,8),new n.ShadowMaterial({opacity:.32}));return i.rotation.x=-Math.PI/2,i.position.y=-.78,i.receiveShadow=!0,t.add(i),{scene:t,camera:e,ground:i}}function nt(n,t){t.outputColorSpace=n.LinearSRGBColorSpace,t.shadowMap.enabled=!0,t.shadowMap.type=n.PCFShadowMap}function ht(n,t,e=3.5){n.aspect=t,n.position.set(0,.5,Math.max(e,e*1.15/t*.9)),n.lookAt(0,-.02,0),n.updateProjectionMatrix()}class rt{constructor(t,e){h(this,"root");h(this,"head");h(this,"eyes");h(this,"body");h(this,"parts");h(this,"paws");h(this,"paper");h(this,"mouth");h(this,"crown");h(this,"motion","static");h(this,"motionAt",0);h(this,"disposables",[]);h(this,"shown","normal");h(this,"yaw",A);h(this,"pitch",0);h(this,"lookX",0);h(this,"lookY",0);h(this,"drawn",!1);h(this,"blinkAt",1500);h(this,"blinkStart",-1e9);h(this,"shakeAt",-1e9);h(this,"start",performance.now());const o=m=>(this.disposables.push(m),m);this.body=o(new t.MeshStandardMaterial({color:e,roughness:.55,metalness:0}));const s=o(new t.MeshBasicMaterial({color:2302495}));this.root=new t.Group,this.head=new t.Group,this.root.add(this.head);const i=o(new t.ExtrudeGeometry(V(t,1.2,.86,.2),{depth:.5,bevelEnabled:!0,bevelSize:.1,bevelThickness:.1,bevelSegments:6,curveSegments:14}));i.center();const c=new t.Mesh(i,this.body);c.castShadow=!0,c.receiveShadow=!0,this.head.add(c);const w=new t.Shape;w.moveTo(-.14,0),w.lineTo(.14,0),w.lineTo(0,.34),w.closePath();const u=o(new t.ExtrudeGeometry(w,{depth:.1,bevelEnabled:!0,bevelSize:.03,bevelThickness:.03,bevelSegments:3}));u.translate(0,0,-.05);for(const m of[-1,1]){const r=new t.Mesh(u,this.body);r.castShadow=!0,r.position.set(m*.42,.44,.04),r.rotation.z=-m*.2,this.head.add(r)}this.eyes=new t.Group,this.eyes.position.set(x,.04,.352),this.head.add(this.eyes);const p=o(new t.ExtrudeGeometry(V(t,.08,.22,.04),{depth:.012,bevelEnabled:!1})),g=Math.PI*.85,a=.085,y=o(new t.TorusGeometry(a,.024,8,24,g)),M=o(new t.SphereGeometry(.024,10,8)),l=Array.from({length:91},(m,r)=>{const v=r/90,S=v*Math.PI*5,k=.012+v*.085;return new t.Vector3(Math.cos(S)*k,Math.sin(S)*k,0)}),f=o(new t.TubeGeometry(new t.CatmullRomCurve3(l),120,.012,6,!1));this.parts=[-.17,.17].map(m=>{const r=new t.Group;r.position.x=m,this.eyes.add(r);const v=new t.Mesh(p,s);r.add(v);const S=new t.Group,k=new t.Mesh(y,s);k.rotation.z=Math.PI/2-g/2,S.add(k);for(const C of[Math.PI/2-g/2,Math.PI/2+g/2]){const I=new t.Mesh(M,s);I.position.set(Math.cos(C)*a,Math.sin(C)*a,0),S.add(I)}S.position.set(0,-.04,.02),r.add(S);const z=new t.Mesh(f,s);return z.position.z=.014,r.add(z),{group:r,pill:v,arc:S,spiral:z}});const G=o(new t.SphereGeometry(1,24,16));this.paws=[-.42,.42].map(m=>{const r=new t.Mesh(G,this.body);return r.castShadow=!0,r.receiveShadow=!0,r.scale.set(.17,.1,.15),r.position.set(m,-.66,.22),this.root.add(r),r}),this.paper=new t.Mesh(o(new t.BoxGeometry(.62,.44,.012)),o(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(o(new t.CircleGeometry(.07,20)),s),this.mouth.position.set(x,-.2,.364),this.mouth.visible=!1,this.head.add(this.mouth),this.crown=new ot(t),this.disposables.push(...this.crown.disposables),this.root.add(this.crown.root),this.root.rotation.y=A,this.show("normal")}setColor(t){this.body.color.setHex(t)}setCrown(t){this.crown.root.visible=t}show(t){this.shown=t;for(const e of this.parts)e.pill.visible=t==="normal"||t==="sad"||t==="angry",e.arc.visible=t==="happy",e.spiral.visible=t==="dizzy"}pose(t){this.show(t),this.root.rotation.y=A,this.head.rotation.set(t==="sad"?.1:t==="angry"?.06:0,0,0),this.head.position.y=0,this.eyes.position.set(x,.04-(t==="sad"?.03:0)-(t==="angry"?.015:0),.352);const e=t==="sad"?.32:t==="angry"?-.38:0;this.parts.forEach((o,s)=>{o.group.scale.y=t==="angry"?.78:1,o.group.rotation.z=s?e:-e});for(const o of this.paws)o.position.y=-.66,o.scale.set(.17,.1,.15);this.crown.place(0,A,0,!0)}shake(t){this.shakeAt=t}frame(t,e){const o=(t-this.start)/1e3,s=e.motion,i=!!e.reduced;s!==this.motion&&(this.motion=s,this.motionAt=t);const c=(t-this.motionAt)/1e3,w=s==="yawn"?Math.sin(Math.PI*Math.min(1,c%3.2/1.8)):0,u=s==="stretch"?Math.sin(Math.PI*Math.min(1,c%3.6/1.8)):0,p=s==="sleep",g=s==="idle"&&this.shown!=="dizzy",a=!p&&this.shown==="dizzy",y=this.shown==="sad",M=this.shown==="angry",l=(d,b)=>i?0:Math.sin(o*d)*b,f=s==="work"||s==="think",G=e.faceX??1,m=(s==="turn"?.05:s==="ask"?.14:s==="read"?A*.6:A)*G,r=s==="idle"||s==="static"?1:p?.25:.45,v=a?0:e.lookX*.22*r,S=a?0:e.lookY*.1*r,k=m+v+(s==="busy"?l(9,.12):0)+(a?l(2.1,.1):0),z=(f?.14:0)+S+(p?.16:0)+(y?.1:0)+(M?.06:0)+(s==="read"?.24+l(.7,.02):0)+(s==="groom"?.1:0)-.2*w-.14*u,C=(a?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),I=(d,b,P)=>this.drawn?d+(b-d)*P:b;this.yaw=I(this.yaw,k,.07),this.pitch=I(this.pitch,z,.1),this.root.rotation.y=this.yaw,this.head.rotation.x=this.pitch,this.head.rotation.z+=(C-this.head.rotation.z)*.2;const U=i?0:s==="work"?Math.sin(o*(e.fast?20:14)):s==="think"?Math.sin(o*4.5)*.45:0,B=Math.max(0,U),L=Math.max(0,-U),j=a?0:e.lookX*(g?.6:.45*r),F=a?0:e.lookY*(g?-.55:.4*r),W=j||(s==="work"?i?0:B>L?-.6:.6:s==="think"?l(.9,.5):s==="busy"?l(9,.5):s==="read"?i?0:c*.8%1*1.2-.6:0),Z=F||(f||s==="read"?-1:p?-.3:0);this.lookX=I(this.lookX,W,.2),this.lookY=I(this.lookY,Z,.15),this.drawn=!0;const q=Math.max(-.2,Math.min(.2,(k-this.yaw)*et));this.eyes.position.x=x*G+q+this.lookX*.06,this.eyes.position.y=.04+this.lookY*.09-(y?.03:0)-(M?.015:0);const J=!p&&(this.shown==="normal"||y||M);s!=="static"&&J&&t-this.start>this.blinkAt&&t-this.blinkStart>400&&(this.blinkStart=t,this.blinkAt=t-this.start+2200+Math.random()*3200),e.mood!==this.shown&&t-this.blinkStart>400&&(this.blinkStart=t);const D=(t-this.blinkStart)/160;e.mood!==this.shown&&D>=.5&&this.show(e.mood);for(const d of this.parts)d.pill.visible=p||this.shown==="normal"||y||M,d.arc.visible=!p&&this.shown==="happy",d.spiral.visible=!p&&this.shown==="dizzy";const K=Math.max(w,u*.9,s==="groom"?.9:0),Q=(p?.1:D>=0&&D<=1?1-.92*Math.sin(Math.PI*D):1)*(1-.88*K),_=p?0:y?.32:M?-.38:0;this.parts.forEach((d,b)=>{d.group.scale.y=Q*(M&&!p?.78:1),d.group.rotation.z+=((b?_:-_)-d.group.rotation.z)*.15,i||(d.spiral.rotation.z+=.14)}),this.paws.forEach((d,b)=>{const P=b?L:B,X=b?1:-1,O=s==="read"?[X*.3,-.44+l(.7,.01),.6]:s==="stretch"?[X*(.42+.2*u),-.66+.62*u,.22-.1*u]:s==="groom"&&b?[.2,-.2+l(7,.035),.5]:s==="turn"&&b?[.4,-.52+l(3,.05),.32]:[X*.42,-.66-.06*P,.22];d.position.x+=(O[0]-d.position.x)*.2,d.position.y+=(O[1]-d.position.y)*.2,d.position.z+=(O[2]-d.position.z)*.2,d.scale.set(.17*(1+.25*P),.1*(1-.3*P),.15*(1+.25*P))}),this.paper.visible=s==="read",this.mouth.visible=w>.05,this.mouth.position.x=x*G+q,this.mouth.scale.set(.8+.3*w,.2+1.3*w,1),this.root.scale.y=1+.05*u,this.head.position.y=(s==="static"?0:p?l(1.2,.02)-.02:l(2,.01))-.03*(B+L)+.04*w+.06*u,this.crown.place(this.head.position.y,this.yaw,o,i);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{rt as CatFigure,nt as configureRenderer,at as createStage,ht as frameCamera};
|