@idosgames/characters 0.1.8 → 0.2.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/dist/{PartsManager-CmrzoyJR.d.cts → PartsManager-CjsNhtVp.d.cts} +1 -1
- package/dist/{PartsManager-BpAUMQXw.d.ts → PartsManager-DzJD-pyV.d.ts} +1 -1
- package/dist/{chunk-JZU255IQ.js → chunk-7P4UMCIQ.js} +1 -1
- package/dist/chunk-MNDPJKUD.js +1 -0
- package/dist/chunk-UFZRW76X.js +2 -0
- package/dist/{chunk-CMQ6UYQV.js → chunk-XUQ63CSO.js} +1 -1
- package/dist/{chunk-I7UPBAMR.js → chunk-YXOP7OHP.js} +1 -1
- package/dist/contract-BtI1o_ow.d.cts +49 -0
- package/dist/contract-BtI1o_ow.d.ts +49 -0
- package/dist/gltf/index.cjs +1 -1
- package/dist/gltf/index.d.cts +1 -1
- package/dist/gltf/index.d.ts +1 -1
- package/dist/gltf/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/rig2d/editor/index.cjs +2 -2
- package/dist/rig2d/editor/index.d.cts +3 -3
- package/dist/rig2d/editor/index.d.ts +3 -3
- package/dist/rig2d/editor/index.js +1 -1
- package/dist/rig2d/index.cjs +4 -4
- package/dist/rig2d/index.d.cts +4 -4
- package/dist/rig2d/index.d.ts +4 -4
- package/dist/rig2d/index.js +1 -1
- package/dist/rig2d/phaser/index.cjs +2 -2
- package/dist/rig2d/phaser/index.d.cts +2 -2
- package/dist/rig2d/phaser/index.d.ts +2 -2
- package/dist/rig2d/phaser/index.js +1 -1
- package/dist/rig2d/three/index.cjs +2 -2
- package/dist/rig2d/three/index.d.cts +2 -2
- package/dist/rig2d/three/index.d.ts +2 -2
- package/dist/rig2d/three/index.js +1 -1
- package/dist/{thumbnail-B7wrQe1B.d.ts → thumbnail-BRsomuLZ.d.ts} +1 -1
- package/dist/{thumbnail-B1WjbWcW.d.cts → thumbnail-CTpr-C1A.d.cts} +1 -1
- package/dist/voxel/index.cjs +15 -15
- package/dist/voxel/index.d.cts +1060 -26
- package/dist/voxel/index.d.ts +1060 -26
- package/dist/voxel/index.js +15 -15
- package/package.json +1 -1
- package/dist/chunk-64D567CX.js +0 -1
- package/dist/chunk-UUX4NEC2.js +0 -2
- package/dist/contract-DhZuKNIf.d.cts +0 -24
- package/dist/contract-DhZuKNIf.d.ts +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idosgames/characters",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Characters of the iDosGames platform in one standard for games and videos: voxel characters (CharacterSpec recipes on three.js), layered 2D characters on a skeleton with a full wardrobe (clothes, hair, weapons, shields) in vector art, and GLB characters on the humanoid-v1 skeleton — one actor contract (emotions, mouth visemes, poses, sockets) and lip-sync from text.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/dist/chunk-64D567CX.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=["neutral","happy","sad","angry","surprised","scared","tired","hurt"];function n(t){return typeof t=="string"&&e.includes(t)}var o=["rest","A","E","O","MBP","FV"];function r(t){return typeof t=="string"&&o.includes(t)}var s=["idle","talk","walk","run","surprised","point","sit","wave","jump","fall","dance"],p=["handR","handL","head"],i=["voxel-warm","flat-cartoon","chibi-2d","low-poly-3d","photo-sticker"];export{e as a,n as b,o as c,r as d,s as e,p as f,i as g};
|
package/dist/chunk-UUX4NEC2.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var It="#1f1a21";var ne="currentColor";function se(s,t,e=1,o={}){let n=Math.max(1,Math.ceil(t.w*e)),r=Math.max(1,Math.ceil(t.h*e)),a=o.paint??s.paint,i=o.light?Ht(t,o.light):"";return `<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${r}" viewBox="0 0 ${t.w} ${t.h}"${a?` color="${a}"`:""}>${i}<g stroke-linejoin="round" stroke-linecap="round"${i?' filter="url(#cel)"':""}>${s.svg}</g></svg>`}var K={depth:.18,min:2.6,max:11,dark:.3,shine:.36};function Ht(s,t){let e=Math.max(K.min,Math.min(K.max,Math.min(s.w,s.h)*K.depth)),o=n=>+n.toFixed(2);return `<defs><filter id="cel" filterUnits="userSpaceOnUse" x="0" y="0" width="${s.w}" height="${s.h}" color-interpolation-filters="sRGB"><feMorphology in="SourceAlpha" operator="erode" radius="${o(3.6*.7)}" result="body"/><feOffset in="body" dx="${o(t.x*e)}" dy="${o(t.y*e)}" result="moved"/><feComposite in="body" in2="moved" operator="out" result="far"/><feFlood flood-color="#000000" flood-opacity="${K.dark}"/><feComposite in2="far" operator="in" result="dark"/><feMorphology in="SourceAlpha" operator="erode" radius="${o(3.6*1.05)}" result="inner"/><feOffset in="inner" dx="${o(-t.x*e*.42)}" dy="${o(-t.y*e*.42)}" result="back"/><feComposite in="inner" in2="back" operator="out" result="near"/><feFlood flood-color="#ffffff" flood-opacity="${K.shine}"/><feComposite in2="near" operator="in" result="shine"/><feMerge><feMergeNode in="SourceGraphic"/><feMergeNode in="dark"/><feMergeNode in="shine"/></feMerge></filter></defs>`}function lt(s={}){let t=s.stroke??It,e=(s.opacity!==void 0?` opacity="${s.opacity}"`:"")+(s.holes?' fill-rule="evenodd"':"");return t==="none"?` stroke="none"${e}`:` stroke="${t}" stroke-width="${s.width??3.6}"${e}`}var jt=(s,t,e)=>`<path d="${s}" fill="${t}"${lt(e)}/>`,Jt=(s,t,e,o,n,r)=>`<ellipse cx="${s}" cy="${t}" rx="${e}" ry="${o}" fill="${n}"${lt(r)}/>`,re=(s,t,e,o,n)=>Jt(s,t,e,e,o,n),ie=(s,t,e,o,n,r,a)=>`<rect x="${s}" y="${t}" width="${e}" height="${o}" rx="${n}" fill="${r}"${lt(a)}/>`,ae=(s,t=It,e=2.2)=>`<path d="${s}" fill="none" stroke="${t}" stroke-width="${e}"/>`,le=(s,t,e)=>jt(s,t,{stroke:"none",...e!==void 0?{opacity:e}:{}}),ce=(s,t,...e)=>`<clipPath id="${s}"><path d="${t}" clip-rule="evenodd"/></clipPath><g clip-path="url(#${s})">${e.join("")}</g>`,he=(s,...t)=>`<g transform="${s}">${t.join("")}</g>`;function de(s,t){let e=parseInt(s.replace("#",""),16),o=i=>Math.max(0,Math.min(255,Math.round(t<0?i*(1+t):i+(255-i)*t))),n=o(e>>16&255),r=o(e>>8&255),a=o(e&255);return `#${(n<<16|r<<8|a).toString(16).padStart(6,"0")}`}var ue="#ffffff";function fe(s){let t=/^#?([0-9a-f]{6})$/i.exec(s.trim());return t?parseInt(t[1],16):16777215}function me(s){return `#${(s&16777215).toString(16).padStart(6,"0")}`}function X(s){let t=(s??"ffffffff").replace("#","").padEnd(8,"f"),e=o=>parseInt(t.slice(o,o+2),16)/255;return {r:e(0),g:e(2),b:e(4),a:e(6)}}var O=Math.PI/180,ct=1e-5;function Pt(s,t){return s.type==="ik"?new A(s,t):new dt(s,t)}var ht=s=>s>180?s-360:s<=-180?s+360:s,A=class{constructor(t,e){this.data=t;this.bones=t.bones.map(o=>e.bones[o.index]),this.target=e.bones[t.target.index],this.mix=t.mix,this.bendDirection=t.bendDirection;}data;mix;bendDirection;bones;target;setupPose(){this.mix=this.data.mix,this.bendDirection=this.data.bendDirection;}sort(t){t.sortBone(this.target);let e=this.bones[0];t.sortBone(e),t.pushConstraint(this),e.sorted=false,t.sortReset(e.children);}update(t){if(this.mix===0)return;let e=this.target.applied;this.bones.length===1?At(t,this.bones[0].applied,e.worldX,e.worldY,this.mix):Wt(t,this.bones[0].applied,this.bones[1].applied,e.worldX,e.worldY,this.bendDirection,this.mix);}};function At(s,t,e,o,n){let r=t.bone.parent;if(!r)return;t.modifyLocal(s);let a=r.applied,i=a.a,d=a.b,l=a.c,c=a.d,p=-t.shearX-t.rotation,h=i*c-d*l,u=e-a.worldX,f=o-a.worldY,m=(u*c-f*d)/h-t.x,b=(f*i-u*l)/h-t.y;p+=Math.atan2(b,m)/O,t.scaleX<0&&(p+=180),t.rotation+=ht(p)*n;}function Wt(s,t,e,o,n,r,a){t.modifyLocal(s),e.modifyLocal(s);let i=t.x,d=t.y,l=t.scaleX,c=t.scaleY,p=e.scaleX,h,u,f;l<0?(l=-l,h=180,f=-1):(h=0,f=1),c<0&&(c=-c,f=-f),p<0?(p=-p,u=180):u=0;let m=Math.abs(l-c)<=ct,b,y;m?(b=t.a*e.x+t.b*e.y+t.worldX,y=t.c*e.x+t.d*e.y+t.worldY):(e.y=0,b=t.a*e.x+t.worldX,y=t.c*e.x+t.worldY);let x=t.bone.parent;if(!x)return;let g=x.applied,w=g.a,M=g.b,st=g.c,rt=g.d,D=w*rt-M*st,F=b-g.worldX,N=y-g.worldY;D=Math.abs(D)<=ct?0:1/D;let xt=(F*rt-N*M)*D-i,kt=(N*w-F*st)*D-d,k=Math.sqrt(xt*xt+kt*kt),P=e.bone.data.length*p;if(k<ct){At(s,t,o,n,a),e.rotation=0;return}F=o-g.worldX,N=n-g.worldY;let H=(F*rt-N*M)*D-i,j=(N*w-F*st)*D-d,G=H*H+j*j,R=0,T=0;if(m){P*=l;let v=(G-k*k-P*P)/(2*k*P);v<-1?(v=-1,T=Math.PI*r):v>1?(v=1,T=0):T=Math.acos(v)*r;let E=k+P*v,C=P*Math.sin(T);R=Math.atan2(j*E-H*C,H*E+j*C);}else {let v=l*P,E=c*P,C=v*v,J=E*E,it=Math.atan2(j,H),S=J*k*k+C*G-C*J,V=-2*J*k,wt=J-C,St=V*V-4*wt*S,Mt=false;if(St>=0){let I=Math.sqrt(St);V<0&&(I=-I),I=-(V+I)*.5;let Y=I/wt,$=S/I,L=Math.abs(Y)<Math.abs($)?Y:$,W=G-L*L;if(W>=0){let B=Math.sqrt(W)*r;R=it-Math.atan2(B,L),T=Math.atan2(B/c,(L-k)/l),Mt=true;}}if(!Mt){let I=Math.PI,Y=k-v,$=Y*Y,L=0,W=0,B=k+v,at=B*B,Tt=0;if(S=-v*k/(C-J),S>=-1&&S<=1){S=Math.acos(S);let _=v*Math.cos(S)+k,U=E*Math.sin(S),Z=_*_+U*U;Z<$&&(I=S,$=Z,Y=_,L=U),Z>at&&(W=S,at=Z,B=_,Tt=U);}G<=($+at)*.5?(R=it-Math.atan2(L*r,Y),T=I*r):(R=it-Math.atan2(Tt*r,B),T=W*r);}}let vt=Math.atan2(e.y,e.x)*f;R=ht((R-vt)/O+h-t.rotation),T=ht(((T+vt)/O-e.shearX)*f+u-e.rotation),t.rotation+=R*a,e.rotation+=T*a;}var dt=class{constructor(t,e){this.data=t;this.source=e.bones[t.source.index],this.bones=t.bones.map(o=>e.bones[o.index]),this.mix={...t.mix};}data;mix;source;bones;setupPose(){Object.assign(this.mix,this.data.mix);}sort(t){t.sortBone(this.source);for(let e of this.bones)t.sortBone(e);t.pushConstraint(this);for(let e of this.bones)t.sortReset(e.children);for(let e of this.bones)e.sorted=true;}update(t){let e=this.mix;if(!e.rotate&&!e.x&&!e.y&&!e.scaleX&&!e.scaleY&&!e.shearY)return;let o=this.source.applied,n=this.data.offsets;for(let r of this.bones){let a=r.applied;a.modifyWorld(t);for(let i of this.data.properties){let d=Kt(t,o,i.prop,n)-i.offset;for(let l of i.to){let c=e[l.prop];c!==0&&qt(t,a,l.prop,l.offset+d*l.scale,c);}}}}};function Kt(s,t,e,o){let n=s.scaleX,r=s.scaleY;switch(e){case "rotate":{let a=(t.a*t.d-t.b*t.c)*n*r>0?1:-1,i=Math.atan2(t.c/r,t.a/n)/O+a*o.rotate;return i<0&&(i+=360),i}case "x":return (o.x*t.a+o.y*t.b+t.worldX)/n;case "y":return (o.x*t.c+o.y*t.d+t.worldY)/r;case "scaleX":return Math.hypot(t.a/n,t.c/r)+o.scaleX;case "scaleY":return Math.hypot(t.b/n,t.d/r)+o.scaleY;case "shearY":return (Math.atan2(t.d/r,t.b/n)-Math.atan2(t.c/r,t.a/n))/O-90+o.shearY}}function qt(s,t,e,o,n){let r=s.scaleX,a=s.scaleY;switch(e){case "rotate":{let i=t.a/r,d=t.b/r,l=t.c/a,c=t.d/a,p=o*O-Math.atan2(l,i);p>Math.PI?p-=2*Math.PI:p<-Math.PI&&(p+=2*Math.PI),p*=n;let h=Math.cos(p),u=Math.sin(p);t.a=(h*i-u*l)*r,t.b=(h*d-u*c)*r,t.c=(u*i+h*l)*a,t.d=(u*d+h*c)*a;return}case "x":t.worldX+=(o-t.worldX/r)*n*r;return;case "y":t.worldY+=(o-t.worldY/a)*n*a;return;case "scaleX":{let i=Math.hypot(t.a/r,t.c/a);i!==0&&(i=1+(o-i)*n/i,t.a*=i,t.c*=i);return}case "scaleY":{let i=Math.hypot(t.b/r,t.d/a);i!==0&&(i=1+(o-i)*n/i,t.b*=i,t.d*=i);return}case "shearY":{let i=t.b/r,d=t.d/a,l=Math.atan2(d,i),c=(o+90)*O;c-=l-Math.atan2(t.c/a,t.a/r),c>Math.PI?c-=2*Math.PI:c<-Math.PI&&(c+=2*Math.PI),c=l+c*n;let p=Math.hypot(i,d);t.b=Math.cos(c)*p*r,t.d=Math.sin(c)*p*a;return}}}var z=class{constructor(t){this.channels=t;}channels;times=[];values=[];kinds=[];samples=[];get count(){return this.times.length}add(t,e){this.times.push(t);for(let o=0;o<this.channels;o++)this.values.push(e[o]??0);this.kinds.push(0);for(let o=0;o<this.channels;o++)this.samples.push(null);}setCurve(t,e){if(e==="stepped"){this.kinds[t]=1;return}if(!Array.isArray(e)||t+1>=this.count)return;this.kinds[t]=2;let o=this.times[t],n=this.times[t+1];for(let r=0;r<this.channels;r++){let a=r*4;if(e.length<a+4)continue;let i=this.values[t*this.channels+r],d=this.values[(t+1)*this.channels+r];this.samples[t*this.channels+r]=Gt(o,i,Number(e[a]),Number(e[a+1]),Number(e[a+2]),Number(e[a+3]),n,d);}}keyAt(t){let e=this.times;if(!e.length||t<e[0])return -1;let o=0,n=e.length-1;for(;o<n;){let r=o+n+1>>1;e[r]<=t?o=r:n=r-1;}return o}value(t,e=0){let o=Math.max(0,this.keyAt(t)),n=this.channels,r=this.values[o*n+e];if(o+1>=this.count)return r;let a=this.kinds[o];if(a===1)return r;let i=this.times[o],d=this.times[o+1],l=this.values[(o+1)*n+e],c=this.samples[o*n+e];if(a!==2||!c)return r+(t-i)/(d-i)*(l-r);if(c[0]>t)return r+(t-i)/(c[0]-i)*(c[1]-r);for(let u=2;u<18;u+=2)if(c[u]>=t){let f=c[u-2],m=c[u-1];return m+(t-f)/(c[u]-f)*(c[u+1]-m)}let p=c[16],h=c[17];return h+(t-p)/(d-p)*(l-h)}};function Gt(s,t,e,o,n,r,a,i){let d=new Float32Array(18);for(let l=1;l<=9;l++){let c=l/10,p=1-c,h=p*p*p,u=3*p*p*c,f=3*p*c*c,m=c*c*c;d[(l-1)*2]=h*s+u*e+f*n+m*a,d[(l-1)*2+1]=h*t+u*o+f*r+m*i;}return d}var Dt=(s,t)=>s.bone!==void 0&&t.bones.has(s.bone)||s.slot!==void 0&&t.slots.has(s.slot),pt=class{constructor(t,e,o,n){this.name=t;this.duration=e;this.timelines=o;this.events=n;}name;duration;timelines;events;apply(t,e){for(let o of this.timelines)o.apply(t,e);}applyOnly(t,e,o){for(let n of this.timelines)Dt(n,o)&&n.apply(t,e);}touches(t){return this.timelines.some(e=>Dt(e,t))}},ut=class{constructor(t,e,o){this.bone=t;this.keys=e;this.props=o;}bone;keys;props;apply(t,e){if(this.keys.keyAt(e)<0)return;let o=t.bones[this.bone],n=o.pose,r=o.data;this.props.forEach((a,i)=>{let d=this.keys.value(e,i);switch(a){case "rotate":n.rotation=r.rotation+d;break;case "x":n.x=r.x+d;break;case "y":n.y=r.y+d;break;case "scaleX":n.scaleX=r.scaleX*d;break;case "scaleY":n.scaleY=r.scaleY*d;break}});}},tt=class{constructor(t,e,o){this.slot=t;this.keys=e;this.channels=o;}slot;keys;channels;apply(t,e){if(this.keys.keyAt(e)<0)return;let o=t.slots[this.slot].color;this.channels.forEach((n,r)=>o[n]=this.keys.value(e,r));}},ft=class{constructor(t,e,o){this.slot=t;this.times=e;this.names=o;}slot;times;names;apply(t,e){if(e<this.times[0])return;let o=0;for(;o+1<this.times.length&&this.times[o+1]<=e;)o++;t.slots[this.slot].attachmentKey=this.names[o];}},mt=class{constructor(t,e,o){this.constraint=t;this.keys=e;this.bends=o;}constraint;keys;bends;apply(t,e){let o=this.keys.keyAt(e);if(o<0)return;let n=t.constraints[this.constraint];n instanceof A&&(n.mix=this.keys.value(e,0),n.bendDirection=this.bends[o]);}};function Q(s,t,e){let o=new z(t);for(let n of s)o.add(n.time??0,e(n));return s.forEach((n,r)=>o.setCurve(r,n.curve)),o}var Vt={rotate:{props:["rotate"],read:s=>[s.value??0]},translate:{props:["x","y"],read:s=>[s.x??0,s.y??0]},translatex:{props:["x"],read:s=>[s.value??0]},translatey:{props:["y"],read:s=>[s.value??0]},scale:{props:["scaleX","scaleY"],read:s=>[s.x??1,s.y??1]},scalex:{props:["scaleX"],read:s=>[s.value??1]},scaley:{props:["scaleY"],read:s=>[s.value??1]}};function Rt(s,t,e){let o=[],n=0,r=i=>{for(let d of i)n=Math.max(n,d.time??0);};for(let[i,d]of Object.entries(t.bones??{})){let l=e.bone(i).index;for(let[c,p]of Object.entries(d)){let h=Vt[c];!h||!p.length||(r(p),o.push(new ut(l,Q(p,h.props.length,h.read),h.props)));}}for(let[i,d]of Object.entries(t.slots??{})){let l=e.slot(i).index;for(let[c,p]of Object.entries(d))if(p.length)if(r(p),c==="attachment")o.push(new ft(l,p.map(h=>h.time??0),p.map(h=>h.name??null)));else if(c==="rgba"||c==="rgb"){let h=c==="rgba"?["r","g","b","a"]:["r","g","b"],u=Q(p,h.length,f=>{let m=X(f.color);return h.map(b=>m[b])});o.push(new tt(l,u,[...h]));}else c==="alpha"&&o.push(new tt(l,Q(p,1,h=>[h.value??0]),["a"]));}for(let[i,d]of Object.entries(t.ik??{})){let l=e.constraints.find(c=>c.type==="ik"&&c.name===i);!l||!d.length||(r(d),o.push(new mt(l.index,Q(d,1,c=>[c.mix??1]),d.map(c=>c.bendPositive===false?-1:1))));}let a=(t.events??[]).map(i=>({time:i.time??0,name:i.name}));for(let i of a)n=Math.max(n,i.time);return new pt(s,n,o,a)}function Ie(s){let t=[],e=new Map;for(let h of s.bones){let u=h.parent?e.get(h.parent)??null:null,f={index:t.length,name:h.name,parent:u,children:[],length:h.length??0,x:h.x??0,y:h.y??0,rotation:h.rotation??0,scaleX:h.scaleX??1,scaleY:h.scaleY??1};u?.children.push(f),t.push(f),e.set(f.name,f);}let o=h=>{let u=e.get(h);if(!u)throw new Error(`no bone ${h}`);return u},n=[],r=new Map;for(let h of s.slots){let u={index:n.length,name:h.name,bone:o(h.bone),attachment:h.attachment??null,color:X(h.color)};n.push(u),r.set(u.name,u);}let a=h=>{let u=r.get(h);if(!u)throw new Error(`no slot ${h}`);return u},i=[];for(let h of s.constraints??[])if(h.type==="ik")i.push({type:"ik",index:i.length,name:h.name,bones:h.bones.map(o),target:o(h.target),mix:h.mix??1,bendDirection:h.bendPositive===false?-1:1});else if(h.type==="transform"){let u=[],f=new Set;for(let[y,x]of Object.entries(h.properties??{})){let g=[];for(let[w,M]of Object.entries(x.to??{}))f.add(w),g.push({prop:w,offset:M.offset??0,max:M.max??1,scale:M.scale??1});g.length&&u.push({prop:y,offset:x.offset??0,to:g});}let m=h.mixX??1,b=h.mixScaleX??1;i.push({type:"transform",index:i.length,name:h.name,source:o(h.source),bones:h.bones.map(o),offsets:{rotate:h.rotation??0,x:h.x??0,y:h.y??0,scaleX:h.scaleX??0,scaleY:h.scaleY??0,shearY:h.shearY??0},mix:{rotate:f.has("rotate")?h.mixRotate??1:0,x:f.has("x")?m:0,y:f.has("y")?h.mixY??m:0,scaleX:f.has("scaleX")?b:0,scaleY:f.has("scaleY")?h.mixScaleY??b:0,shearY:f.has("shearY")?h.mixShearY??1:0},properties:u});}let d=new Map,l=[],c=[];for(let h of s.skins){let u={name:h.name,attachments:new Map};for(let[f,m]of Object.entries(h.attachments??{})){let b=a(f).index,y=new Map;u.attachments.set(b,y);for(let[x,g]of Object.entries(m)){let w=g.type??"region";w==="linkedmesh"?c.push({skin:u,slot:b,key:x,a:g}):y.set(x,_t(x,g,w));}}d.set(u.name,u),l.push(u.name);}for(let{skin:h,slot:u,key:f,a:m}of c){let y=(d.get(m.skin??"default")??h).attachments.get(u)?.get(m.source??m.parent);if(!y||y.type!=="mesh")throw new Error(`linked mesh ${h.name}/${f}: no source mesh`);h.attachments.get(u).set(f,{...y,key:f,path:m.path??m.name??f,width:m.width??y.width,height:m.height??y.height,color:X(m.color)});}let p={width:s.skeleton?.width??0,height:s.skeleton?.height??0,x:s.skeleton?.x??0,y:s.skeleton?.y??0,bones:t,slots:n,constraints:i,skins:d,skinOrder:l,animations:new Map,events:Object.keys(s.events??{}),bone:o,slot:a};for(let[h,u]of Object.entries(s.animations??{}))p.animations.set(h,Rt(h,u,p));return p}function _t(s,t,e){let o=t.path??t.name??s;if(e==="mesh"){let n=Float32Array.from(t.uvs),r=n.length/2,a=t.vertices;return {type:"mesh",key:s,path:o,uvs:n,triangles:Uint16Array.from(t.triangles),vertices:Float32Array.from(a),weighted:a.length>n.length,vertexCount:r,width:t.width??0,height:t.height??0,color:X(t.color)}}return {type:"region",key:s,path:o,x:t.x??0,y:t.y??0,rotation:t.rotation??0,scaleX:t.scaleX??1,scaleY:t.scaleY??1,width:t.width??0,height:t.height??0,color:X(t.color)}}var Ct=new WeakMap;function Pe(s){let t=Ct.get(s);if(t)return t;t=new Map;for(let e of s.skins.values())for(let o of e.attachments.values())for(let n of o.values())t.has(n.path)||t.set(n.path,{w:n.width,h:n.height});return Ct.set(s,t),t}function Ae(s,t){let e=s.skins.get(t);if(!e)return [];let o=new Set;for(let n of e.attachments.values())for(let r of n.values())o.add(r.path);return [...o]}var q=Math.PI/180,yt=1e-5,et=class{constructor(t){this.bone=t;}bone;x=0;y=0;rotation=0;scaleX=1;scaleY=1;shearX=0;shearY=0;a=1;b=0;c=0;d=1;worldX=0;worldY=0;world=0;local=0;copyLocal(t){this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY;}update(t){this.world!==t.updateId&&this.updateWorldTransform(t);}updateWorldTransform(t){this.local===t.updateId?this.updateLocalTransform(t):this.world=t.updateId;let e=(this.rotation+this.shearX)*q,o=(this.rotation+90+this.shearY)*q,n=Math.cos(e)*this.scaleX,r=Math.cos(o)*this.scaleY,a=Math.sin(e)*this.scaleX,i=Math.sin(o)*this.scaleY,d=this.bone.parent;if(!d){let c=t.scaleX,p=t.scaleY;this.a=n*c,this.b=r*c,this.c=a*p,this.d=i*p,this.worldX=this.x*c+t.x,this.worldY=this.y*p+t.y;return}let l=d.applied;this.worldX=l.a*this.x+l.b*this.y+l.worldX,this.worldY=l.c*this.x+l.d*this.y+l.worldY,this.a=l.a*n+l.b*a,this.b=l.a*r+l.b*i,this.c=l.c*n+l.d*a,this.d=l.c*r+l.d*i;}updateLocalTransform(t){this.local=0,this.world=t.updateId;let e=this.bone.parent;if(!e){this.x=(this.worldX-t.x)/t.scaleX,this.y=(this.worldY-t.y)/t.scaleY,this.set5(this.a/t.scaleX,this.b/t.scaleX,this.c/t.scaleY,this.d/t.scaleY);return}let o=e.applied,n=1/(o.a*o.d-o.b*o.c),r=o.d*n,a=o.b*n,i=o.c*n,d=o.a*n,l=this.worldX-o.worldX,c=this.worldY-o.worldY;this.x=l*r-c*a,this.y=c*d-l*i,this.set5(r*this.a-a*this.c,r*this.b-a*this.d,d*this.c-i*this.a,d*this.d-i*this.b);}set5(t,e,o,n){this.shearX=0;let r=t*t+o*o,a=e*e+n*n;if(r>yt){let i=Math.atan2(o,t)/q;this.rotation=i,this.scaleX=Math.sqrt(r),this.scaleY=Math.sqrt(a),a>yt?(this.shearY=Math.atan2(n,e)/q,t*n-e*o<0?(this.scaleY=-this.scaleY,this.shearY+=90-i):this.shearY-=90+i,this.shearY>180?this.shearY-=360:this.shearY<=-180&&(this.shearY+=360)):this.shearY=0;}else this.scaleX=0,this.scaleY=Math.sqrt(a),this.shearY=0,this.rotation=a>yt?Math.atan2(n,e)/q-90:0;}modifyLocal(t){this.local===t.updateId&&this.updateLocalTransform(t),this.world=0,this.resetWorld(t);}modifyWorld(t){this.local=t.updateId,this.world=t.updateId,this.resetWorld(t);}resetWorld(t){for(let e of this.bone.children){let o=e.applied;o.world===t.updateId&&(o.local===t.updateId&&o.updateLocalTransform(t),o.world=0,o.resetWorld(t));}}},ot=class{constructor(t){this.data=t;this.pose=new et(this),this.applied=new et(this),this.setupPose();}data;pose;applied;parent=null;children=[];sorted=false;setupPose(){let t=this.data,e=this.pose;e.x=t.x,e.y=t.y,e.rotation=t.rotation,e.scaleX=t.scaleX,e.scaleY=t.scaleY,e.shearX=0,e.shearY=0;}},bt=class{constructor(t,e){this.data=t;this.bone=e;this.color={...t.color},this.attachmentKey=t.attachment;}data;bone;color;attachmentKey;attachment=null},nt=class{constructor(t){this.data=t;this.bones=t.bones.map(e=>new ot(e));for(let e of this.bones)e.data.parent&&(e.parent=this.bones[e.data.parent.index],e.parent.children.push(e));this.slots=t.slots.map(e=>new bt(e,this.bones[e.bone.index])),this.constraints=t.constraints.map(e=>Pt(e,this)),this.updateCache();}data;bones;slots;constraints;skins=[];scaleX=1;scaleY=1;x=0;y=0;updateId=0;cache=[];bone(t){return this.bones[this.data.bone(t).index]}slot(t){return this.slots[this.data.slot(t).index]}setSkins(t){this.skins=[...t],this.resolveAttachments();}getAttachment(t,e){for(let o=this.skins.length-1;o>=0;o--){let n=this.skins[o].attachments.get(t)?.get(e);if(n)return n}return null}resolveAttachments(){for(let t of this.slots)t.attachment=t.attachmentKey?this.getAttachment(t.data.index,t.attachmentKey):null;}setupPose(){for(let t of this.bones)t.setupPose();for(let t of this.constraints)t.setupPose();for(let t of this.slots)Object.assign(t.color,t.data.color),t.attachmentKey=t.data.attachment;}updateWorldTransform(){this.updateId++;for(let t of this.bones)t.applied.copyLocal(t.pose),t.applied.world=0,t.applied.local=0;for(let t of this.cache)t instanceof ot?t.applied.update(this):t.update(this);}updateCache(){this.cache=[];for(let t of this.bones)t.sorted=false;for(let t of this.constraints)t.sort(this);for(let t of this.bones)this.sortBone(t);}sortBone(t){t.sorted||(t.parent&&this.sortBone(t.parent),t.sorted=true,this.cache.push(t));}sortReset(t){for(let e of t)e.sorted&&this.sortReset(e.children),e.sorted=false;}pushConstraint(t){this.cache.push(t);}};var Yt=class{constructor(t,e,o=.2){this.skeleton=t;this.data=e;this.defaultMix=o;this.snapshot=new Float32Array(t.bones.length*5),this.slotSnapshot=new Float32Array(t.slots.length*4),this.ikSnapshot=new Float32Array(t.constraints.length);}skeleton;data;defaultMix;track=null;previous=null;mixTime=0;mixDuration=0;listeners=new Map;snapshot;slotSnapshot;ikSnapshot;blink=null;setBlink(t){let e=t?this.data.animations.get(t.animation):void 0;if(!t||!e){this.blink=null;return}let o={bones:new Set(t.bones.map(n=>this.data.bone(n).index)),slots:new Set(t.slots.map(n=>this.data.slot(n).index))};this.blink={source:e,filter:o,options:t,wait:this.nextBlink(t),at:-1};}blinkNow(){this.blink&&(this.blink.at=0);}blinking(){return (this.blink?.at??-1)>=0}setRandom(t){this.random=t;}random=Math.random;nextBlink(t){return t.every[0]+this.random()*(t.every[1]-t.every[0])}names(){return [...this.data.animations.keys()]}has(t){return this.data.animations.has(t)}play(t,e={}){let o=this.data.animations.get(t);if(!o)return false;let n=e.mix??this.defaultMix;return this.previous=this.track&&n>0?this.track:null,this.mixTime=0,this.mixDuration=this.previous?n:0,this.track={animation:o,time:Math.max(0,e.from??0),speed:e.speed??1,loop:e.loop??true,done:false},true}current(){return this.track?.animation.name??null}time(){return this.track?this.local(this.track):0}duration(){return this.track?.animation.duration??0}finished(){return this.track?.done??false}setSpeed(t){this.track&&(this.track.speed=t);}on(t,e){let o=this.listeners.get(t)??new Set;return o.add(e),this.listeners.set(t,o),()=>o.delete(e)}update(t){let e=[],o=this.track;if(o&&!o.done){let n=o.time;o.time+=Math.max(0,t)*o.speed,this.collect(o,n,o.time,e),!o.loop&&o.time>=o.animation.duration&&(o.time=o.animation.duration,o.done=true,e.push({name:"end",animation:o.animation.name}));}if(this.previous){let n=this.previous;n.time+=Math.max(0,t)*n.speed,this.mixTime+=Math.max(0,t),this.mixTime>=this.mixDuration&&(this.previous=null);}this.advanceBlink(Math.max(0,t)),this.pose();for(let n of e){for(let r of this.listeners.get(n.name)??[])r(n);for(let r of this.listeners.get("*")??[])r(n);}}pose(){let t=this.skeleton,e=this.previous;e&&this.mixDuration>0&&(t.setupPose(),e.animation.apply(t,this.local(e)),this.save()),t.setupPose(),this.track&&this.track.animation.apply(t,this.local(this.track)),e&&this.mixDuration>0&&this.blendFromSaved(Math.min(1,this.mixTime/this.mixDuration));let o=this.blink;o&&o.at>=0&&o.source.applyOnly(t,o.options.from+o.at,o.filter),t.resolveAttachments();}advanceBlink(t){let e=this.blink;if(e){if(this.track?.animation.touches(e.filter)){e.at=-1;return}if(e.at>=0){e.at+=t,e.at>=e.options.to-e.options.from&&(e.at=-1,e.wait=this.nextBlink(e.options));return}e.wait-=t,e.wait<=0&&(e.at=0);}}local(t){let e=t.animation.duration;return e<=0?0:t.loop?t.time%e:Math.min(t.time,e)}collect(t,e,o,n){let r=t.animation.duration;if(r<=0||o<=e)return;let a=Math.floor(e/r),i=t.loop?Math.floor(o/r):0;for(let d=a;d<=i;d++)for(let l of t.animation.events){let c=d*r+l.time;c>=e&&(c<o||!t.loop&&c<=o)&&n.push({name:l.name,animation:t.animation.name});}}save(){let t=this.skeleton;t.bones.forEach((e,o)=>{let n=e.pose;this.snapshot.set([n.x,n.y,n.rotation,n.scaleX,n.scaleY],o*5);}),t.slots.forEach((e,o)=>this.slotSnapshot.set([e.color.r,e.color.g,e.color.b,e.color.a],o*4)),t.constraints.forEach((e,o)=>{e instanceof A&&(this.ikSnapshot[o]=e.mix);});}blendFromSaved(t){let e=this.skeleton,o=(n,r)=>n+(r-n)*t;e.bones.forEach((n,r)=>{let a=this.snapshot,i=n.pose,d=r*5;i.x=o(a[d],i.x),i.y=o(a[d+1],i.y);let l=i.rotation-a[d+2];l-=Math.round(l/360)*360,i.rotation=a[d+2]+l*t,i.scaleX=o(a[d+3],i.scaleX),i.scaleY=o(a[d+4],i.scaleY);}),e.slots.forEach((n,r)=>{let a=this.slotSnapshot;n.color.r=o(a[r*4],n.color.r),n.color.g=o(a[r*4+1],n.color.g),n.color.b=o(a[r*4+2],n.color.b),n.color.a=o(a[r*4+3],n.color.a);}),e.constraints.forEach((n,r)=>{n instanceof A&&(n.mix=o(this.ikSnapshot[r],n.mix));});}};var Lt=Math.PI/180,Ut=new Float32Array([0,1,0,0,1,0,1,1]),Zt=new Uint16Array([0,1,2,2,3,0]),Bt=new WeakMap;function zt(s){let t=Bt.get(s);if(t)return t;let e=-s.width/2*s.scaleX,o=-s.height/2*s.scaleY,n=s.width/2*s.scaleX,r=s.height/2*s.scaleY,a=Math.cos(s.rotation*Lt),i=Math.sin(s.rotation*Lt),d=(l,c)=>[l*a-c*i+s.x,l*i+c*a+s.y];return t=Float32Array.from([...d(e,o),...d(e,r),...d(n,r),...d(n,o)]),Bt.set(s,t),t}function Xt(s,t,e,o){if(e.type==="region"){let n=o&&o.length===8?o:new Float32Array(8),r=zt(e),a=t.bone.applied;for(let i=0;i<8;i+=2){let d=r[i],l=r[i+1];n[i]=d*a.a+l*a.b+a.worldX,n[i+1]=d*a.c+l*a.d+a.worldY;}return {positions:n,uvs:Ut,triangles:Zt}}return Qt(s,t,e,o)}function Qt(s,t,e,o){let n=e.vertexCount*2,r=o&&o.length===n?o:new Float32Array(n),a=e.vertices;if(e.weighted){let i=0;for(let d=0;d<n;d+=2){let l=a[i++],c=0,p=0;for(let h=0;h<l;h++,i+=4){let u=s.bones[a[i]].applied,f=a[i+1],m=a[i+2],b=a[i+3];c+=(f*u.a+m*u.b+u.worldX)*b,p+=(f*u.c+m*u.d+u.worldY)*b;}r[d]=c,r[d+1]=p;}}else {let i=t.bone.applied;for(let d=0;d<n;d+=2){let l=a[d],c=a[d+1];r[d]=l*i.a+c*i.b+i.worldX,r[d+1]=l*i.c+c*i.d+i.worldY;}}return {positions:r,uvs:e.uvs,triangles:e.triangles}}var Ot=2;function Xe(...s){let t={v:2,parts:{},colors:{}},e;for(let o of s)o&&(Object.assign(t.parts,o.parts),Object.assign(t.colors,o.colors),o.body&&(e={...e,...o.body}));return e&&(t.body=e),t}function te(s){if(!s||typeof s!="object")return null;let t=s,e={},o=t.race;return typeof o=="string"&&/^[a-z][a-z0-9_-]{0,31}$/.test(o)&&(e.race=o),Object.keys(e).length?e:null}function Oe(s){if(!s||typeof s!="object")return null;let t=s;if(t.v!==1&&t.v!==2)return null;let e={},o={};if(t.parts&&typeof t.parts=="object")for(let[r,a]of Object.entries(t.parts))(a===null||typeof a=="string")&&(e[r]=a);if(t.colors&&typeof t.colors=="object")for(let[r,a]of Object.entries(t.colors))typeof a=="string"&&/^#[0-9a-f]{6}$/i.test(a)&&(o[r]=a);let n=t.v===2?te(t.body):null;return {v:2,parts:e,colors:o,...n?{body:n}:{}}}function $e(s){let t=s>>>0;return ()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function Fe(s){let t=2166136261;for(let e=0;e<s.length;e++)t=Math.imul(t^s.charCodeAt(e),16777619);return t>>>0}function gt(s,t){return t.length?t[Math.floor(s()*t.length)]:void 0}var ee=/^[a-z][a-z0-9_-]{0,31}$/,Et=class{races=new Map;constructor(t=[]){for(let e of t)this.register(e);}register(t){if(!ee.test(t.id))throw new Error(`race: bad id "${t.id}"`);if(!t.names.en)throw new Error(`race ${t.id}: no English name`);for(let e of t.skin??[])if(!/^#[0-9a-f]{6}$/i.test(e))throw new Error(`race ${t.id}: bad skin colour ${e}`);return this.races.set(t.id,t),this}get(t){return t&&this.races.get(t)||null}has(t){return this.races.has(t)}list(){return [...this.races.values()]}ids(){return [...this.races.keys()]}};function je(s,t="en"){return s.names[t]??s.names.en}function Je(){return {id:"race",apply(s){let t=s.race();if(t){for(let[e,o]of Object.entries(t.parts??{}))s.setWorn(e,o&&s.exists(o)?o:null);for(let[e,o]of Object.entries(t.replace??{}))for(let n of s.types())s.worn(n)===e&&s.setWorn(n,o&&s.exists(o)?o:null);for(let[e,o]of Object.entries(t.ban??{})){let n=s.worn(e);n&&(o==="all"||o.includes(n))&&s.setWorn(e,null);}}}}}function $t(s,t){return !s.skin?.length||s.skin.some(e=>e.toLowerCase()===t.toLowerCase())}function We(s,t,e="Skin"){let o={...s.defaults??{}};if(t)for(let[a,i]of Object.entries(s.options??{})){let d=gt(t,i);d!==void 0&&(o[a]=d);}let n={...s.colors??{}},r=t?gt(t,s.skin??[]):s.skin?.[0];return r&&(n[e]=r),{v:2,body:{race:s.id},parts:o,colors:n}}var Ft=class{constructor(t,e=()=>true){this.rig=t;this.drawable=e;let o=(n,r)=>t.colorTargets.find(a=>(a.into??"tint")===r&&a.slotPrefixes.some(i=>n.startsWith(i)))?.id??null;this.slotTarget=t.data.slots.map(n=>o(n.name,"tint")),this.slotArt=t.data.slots.map(n=>o(n.name,"art")),this.rebuildLists(),this.init();}rig;drawable;chosen=new Map;hidden=new Map;colors=new Map;lists=new Map;listeners=new Set;slotTarget;slotArt;face=null;emotionFace=null;speech="rest";body={};raceSaved=new Map;raceGiven=new Map;setDrawable(t){let e=new Set(this.rig.partTypes.filter(o=>!this.count(o.id)).map(o=>o.id));this.drawable=t,this.rebuildLists();for(let o of this.rig.partTypes){if(o.auto)continue;let n=this.chosen.get(o.id);(n&&!this.lists.get(o.id).includes(n)||!n&&e.has(o.id))&&this.chosen.set(o.id,this.first(o));}this.emit({kind:"part",type:"*",skin:null});}on(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t){for(let e of [...this.listeners])e(t);}typeDef(t){return this.rig.partTypes.find(e=>e.id===t)}list(t){return this.lists.get(t)??[]}count(t){return this.list(t).length}part(t){return this.chosen.get(t)??null}index(t){let e=this.part(t);return e?this.list(t).indexOf(e):-1}isHidden(t){return this.hidden.get(t)??false}isWorn(t){return this.part(t)!==null&&!this.isHidden(t)}color(t){return this.colors.get(t)??null}wornSkins(){let t=new Map;for(let l of this.rig.partTypes)t.set(l.id,!l.auto&&this.isWorn(l.id)?this.part(l.id):null);let e={worn:l=>t.get(l)??null,setWorn:(l,c)=>t.set(l,c),exists:l=>this.rig.data.skins.has(l)&&this.drawable(l),race:()=>this.race(),types:()=>this.rig.partTypes.map(l=>l.id)};for(let l of this.rig.rules)l.apply(e);let o=this.rig.expressions,n=this.face??this.emotionFace,r=n?o?.faces[n]:void 0;for(let[l,c]of Object.entries(r??{}))t.get(l)&&e.exists(c)&&t.set(l,c);let a=this.speech!=="rest"?o?.speech:void 0,i=a?.visemes[this.speech];a&&i&&t.get(a.type)&&e.exists(i)&&t.set(a.type,i);let d=[];for(let l of this.rig.partTypes){let c=t.get(l.id);c&&d.push(c);}return d}slotColor(t){let e=this.slotTarget[t];return e?this.color(e):null}artColor(t){let e=this.slotArt[t];return e?this.color(e):null}bodyLook(){return {...this.body}}race(){return this.rig.races?.get(this.body.race)??null}expression(){return this.face}equip(t,e){let o=this.lists.get(t);if(!o)return;let n;if(e===null||e===-1)n=null;else if(typeof e=="number")n=o[Math.max(0,Math.min(o.length-1,e))]??null;else if(o.includes(e))n=e;else return;n===null&&!this.typeDef(t)?.canHide||(this.chosen.set(t,n),this.emit({kind:"part",type:t,skin:n}));}unequip(t){this.equip(t,null);}setHidden(t,e){this.typeDef(t)?.canHide&&(this.hidden.set(t,e),this.emit({kind:"hidden",type:t,hidden:e}));}next(t){let e=this.count(t);if(!e)return;let o=this.index(t);this.typeDef(t)?.canHide?this.equip(t,o>=e-1?-1:o+1):this.equip(t,(o+1)%e);}prev(t){let e=this.count(t);if(!e)return;let o=this.index(t);this.typeDef(t)?.canHide?this.equip(t,o<=-1?e-1:o-1):this.equip(t,(o-1+e)%e);}setColor(t,e){this.colors.set(t,e),this.emit({kind:"color",target:t,color:e});}setExpression(t){let e=t&&this.rig.expressions?.faces[t]?t:null;e!==this.face&&(this.face=e,this.emit({kind:"expression",name:e}));}setEmotion(t){let e=this.rig.expressions?.emotions?.[t]??null,o=e&&this.rig.expressions?.faces[e]?e:null;o!==this.emotionFace&&(this.emotionFace=o,this.emit({kind:"expression",name:this.face??o}));}setSpeech(t){t!==this.speech&&(this.speech=t,this.emit({kind:"speech",viseme:t}));}setBody(t){let e=this.race();if(this.body={...t},this.body.race!==e?.id){this.dropRaceColors();let o=new Map(this.colors);this.fitRaceColors(false),this.rememberRaceColors(o);}this.emit({kind:"body",body:this.bodyLook()});}setRace(t){let e={...this.body};t?e.race=t:delete e.race,this.setBody(e);}randomize(t=Math.random){for(let e of this.rig.partTypes){if(e.auto)continue;let o=this.count(e.id);o&&this.equip(e.id,e.canHide&&t()<.3?-1:Math.floor(t()*o));}}reset(){this.init();for(let t of this.rig.partTypes)this.emit({kind:"part",type:t.id,skin:this.part(t.id)});}toLook(){let t={};for(let n of this.rig.partTypes)n.auto||(t[n.id]=this.isWorn(n.id)?this.part(n.id):null);let e={};for(let[n,r]of this.colors)r&&(e[n]=r);let o=this.bodyLook();return {v:2,parts:t,colors:e,...Object.keys(o).length?{body:o}:{}}}applyLook(t){let e=this.race(),o=!!t.body&&t.body.race!==e?.id;o&&this.dropRaceColors();let n=new Map(this.colors);for(let[r,a]of Object.entries(t.parts??{}))a===void 0||this.typeDef(r)?.auto||(this.equip(r,a),a!==null&&this.part(r)===a&&this.hidden.set(r,false));for(let[r,a]of Object.entries(t.colors??{}))a&&this.setColor(r,a);t.body&&(this.body={...this.body,...t.body},o&&(this.fitRaceColors(true,t),this.rememberRaceColors(n)),this.emit({kind:"body",body:this.bodyLook()}));}dropRaceColors(){for(let[t,e]of this.raceGiven)this.color(t)?.toLowerCase()===e.toLowerCase()&&this.setColor(t,this.raceSaved.get(t)??null);this.raceGiven.clear(),this.raceSaved.clear();}rememberRaceColors(t){let e=this.race();if(!e)return;let o=new Set(Object.keys(e.colors??{}));e.skin?.length&&o.add(this.rig.skinColor??"Skin");for(let n of o){let r=this.color(n);!r||r===(t.get(n)??null)||(this.raceSaved.set(n,t.get(n)??null),this.raceGiven.set(n,r));}}fitRaceColors(t,e){let o=this.race();if(!o)return;for(let[i,d]of Object.entries(o.colors??{}))(t?e?.colors?.[i]:this.color(i))||this.setColor(i,d);let n=this.rig.skinColor??"Skin",r=this.color(n),a=t?e?.colors?.[n]??r:r;o.skin?.length&&(!a||!$t(o,a))&&this.setColor(n,o.skin[0]);}rebuildLists(){for(let t of this.rig.partTypes)this.lists.set(t.id,this.rig.data.skinOrder.filter(e=>e.startsWith(t.skinPrefix)&&this.drawable(e)));}first(t){return this.lists.get(t.id)?.[0]??null}init(){this.chosen.clear(),this.hidden.clear(),this.colors.clear(),this.body={},this.raceSaved.clear(),this.raceGiven.clear();for(let t of this.rig.partTypes)this.chosen.set(t.id,t.auto?null:this.first(t));}};var Nt=new WeakMap;function Ue(s,t){let e=Nt.get(s);if(e)return e;e=new Map;let o=new nt(s);o.setupPose(),o.updateWorldTransform();let[n,r]=t.light;for(let a of s.skins.values())for(let[i,d]of a.attachments)for(let l of d.values()){if(e.has(l.path)||t.skip?.some(b=>l.path.startsWith(b)))continue;let c=Xt(o,o.slots[i],l,null),p=oe(c.positions,c.uvs,l.width,l.height);if(!p)continue;let h=p.a*p.d-p.b*p.c;if(Math.abs(h)<1e-9)continue;let u=(p.d*n-p.b*r)/h,f=(-p.c*n+p.a*r)/h,m=Math.hypot(u,f)||1;e.set(l.path,{x:u/m,y:f/m});}return Nt.set(s,e),e}function oe(s,t,e,o){let n=t.length/2;if(n<3)return null;let r=0,a=0,i=0,d=0;for(let y=0;y<n;y++)r+=t[y*2]*e,a+=t[y*2+1]*o,i+=s[y*2],d+=s[y*2+1];r/=n,a/=n,i/=n,d/=n;let l=0,c=0,p=0,h=0,u=0,f=0,m=0;for(let y=0;y<n;y++){let x=t[y*2]*e-r,g=t[y*2+1]*o-a,w=s[y*2]-i,M=s[y*2+1]-d;l+=x*x,c+=x*g,p+=g*g,h+=w*x,u+=w*g,f+=M*x,m+=M*g;}let b=l*p-c*c;return Math.abs(b)<1e-9?null:{a:(h*p-u*c)/b,b:(u*l-h*c)/b,c:(f*p-m*c)/b,d:(m*l-f*c)/b}}
|
|
2
|
-
export{Xe as A,te as B,Oe as C,$e as D,Fe as E,gt as F,Et as G,je as H,Je as I,$t as J,We as K,Ft as L,Ue as M,It as a,ne as b,se as c,jt as d,Jt as e,re as f,ie as g,ae as h,le as i,ce as j,he as k,de as l,ue as m,fe as n,me as o,X as p,pt as q,Ie as r,Pe as s,Ae as t,ot as u,bt as v,nt as w,Yt as x,Xt as y,Ot as z};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/** Эмоции. Шесть из стандарта ассетов (нейтрально, радость, грусть, злость, удивление, страх) + устал и больно. */
|
|
2
|
-
declare const EMOTIONS: readonly ["neutral", "happy", "sad", "angry", "surprised", "scared", "tired", "hurt"];
|
|
3
|
-
type Emotion = (typeof EMOTIONS)[number];
|
|
4
|
-
declare function isEmotion(v: unknown): v is Emotion;
|
|
5
|
-
/**
|
|
6
|
-
* Фонемы рта (визимы) — шесть форм, которых хватает мультяшной речи: покой, «А», «Э/И», «О/У»,
|
|
7
|
-
* сомкнутые губы (М, Б, П) и губа к зубам (Ф, В).
|
|
8
|
-
*/
|
|
9
|
-
declare const VISEMES: readonly ["rest", "A", "E", "O", "MBP", "FV"];
|
|
10
|
-
type Viseme = (typeof VISEMES)[number];
|
|
11
|
-
declare function isViseme(v: unknown): v is Viseme;
|
|
12
|
-
/** Позы, которые умеет любой гуманоид контракта (у 2D — анимации рига, у вокселей — жесты, у GLB — клипы). */
|
|
13
|
-
declare const ACTOR_POSES: readonly ["idle", "talk", "walk", "run", "surprised", "point", "sit", "wave", "jump", "fall", "dance"];
|
|
14
|
-
type ActorPose = (typeof ACTOR_POSES)[number];
|
|
15
|
-
/** Сокеты для пропсов: правая и левая рука, головной убор. */
|
|
16
|
-
declare const ACTOR_SOCKETS: readonly ["handR", "handL", "head"];
|
|
17
|
-
type ActorSocket = (typeof ACTOR_SOCKETS)[number];
|
|
18
|
-
/** Вид актёра (вид ассета каталога). */
|
|
19
|
-
type ActorKind = "voxel" | "rig2d" | "gltf" | "cutout";
|
|
20
|
-
/** Стилевые семейства: ассеты разных семейств по умолчанию не смешиваются в одном ролике. */
|
|
21
|
-
declare const STYLE_FAMILIES: readonly ["voxel-warm", "flat-cartoon", "chibi-2d", "low-poly-3d", "photo-sticker"];
|
|
22
|
-
type StyleFamily = (typeof STYLE_FAMILIES)[number];
|
|
23
|
-
|
|
24
|
-
export { type ActorSocket as A, type Emotion as E, STYLE_FAMILIES as S, type Viseme as V, ACTOR_POSES as a, ACTOR_SOCKETS as b, type ActorKind as c, type ActorPose as d, EMOTIONS as e, type StyleFamily as f, VISEMES as g, isViseme as h, isEmotion as i };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/** Эмоции. Шесть из стандарта ассетов (нейтрально, радость, грусть, злость, удивление, страх) + устал и больно. */
|
|
2
|
-
declare const EMOTIONS: readonly ["neutral", "happy", "sad", "angry", "surprised", "scared", "tired", "hurt"];
|
|
3
|
-
type Emotion = (typeof EMOTIONS)[number];
|
|
4
|
-
declare function isEmotion(v: unknown): v is Emotion;
|
|
5
|
-
/**
|
|
6
|
-
* Фонемы рта (визимы) — шесть форм, которых хватает мультяшной речи: покой, «А», «Э/И», «О/У»,
|
|
7
|
-
* сомкнутые губы (М, Б, П) и губа к зубам (Ф, В).
|
|
8
|
-
*/
|
|
9
|
-
declare const VISEMES: readonly ["rest", "A", "E", "O", "MBP", "FV"];
|
|
10
|
-
type Viseme = (typeof VISEMES)[number];
|
|
11
|
-
declare function isViseme(v: unknown): v is Viseme;
|
|
12
|
-
/** Позы, которые умеет любой гуманоид контракта (у 2D — анимации рига, у вокселей — жесты, у GLB — клипы). */
|
|
13
|
-
declare const ACTOR_POSES: readonly ["idle", "talk", "walk", "run", "surprised", "point", "sit", "wave", "jump", "fall", "dance"];
|
|
14
|
-
type ActorPose = (typeof ACTOR_POSES)[number];
|
|
15
|
-
/** Сокеты для пропсов: правая и левая рука, головной убор. */
|
|
16
|
-
declare const ACTOR_SOCKETS: readonly ["handR", "handL", "head"];
|
|
17
|
-
type ActorSocket = (typeof ACTOR_SOCKETS)[number];
|
|
18
|
-
/** Вид актёра (вид ассета каталога). */
|
|
19
|
-
type ActorKind = "voxel" | "rig2d" | "gltf" | "cutout";
|
|
20
|
-
/** Стилевые семейства: ассеты разных семейств по умолчанию не смешиваются в одном ролике. */
|
|
21
|
-
declare const STYLE_FAMILIES: readonly ["voxel-warm", "flat-cartoon", "chibi-2d", "low-poly-3d", "photo-sticker"];
|
|
22
|
-
type StyleFamily = (typeof STYLE_FAMILIES)[number];
|
|
23
|
-
|
|
24
|
-
export { type ActorSocket as A, type Emotion as E, STYLE_FAMILIES as S, type Viseme as V, ACTOR_POSES as a, ACTOR_SOCKETS as b, type ActorKind as c, type ActorPose as d, EMOTIONS as e, type StyleFamily as f, VISEMES as g, isViseme as h, isEmotion as i };
|