@margoengine/animation 0.0.0-stage → 1.0.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.
Files changed (70) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +1172 -2
  4. package/dist/batch.d.ts +162 -0
  5. package/dist/clip-utils.d.ts +50 -0
  6. package/dist/clip-utils.js +1 -0
  7. package/dist/clone.d.ts +15 -0
  8. package/dist/cor.d.ts +52 -0
  9. package/dist/cor.js +17 -0
  10. package/dist/deform-readers-DmYAkvBK.js +1 -0
  11. package/dist/deform-readers.d.ts +5 -0
  12. package/dist/deformed-points.d.ts +87 -0
  13. package/dist/deformed-points.js +17 -0
  14. package/dist/discrete-tracks.d.ts +102 -0
  15. package/dist/discrete-tracks.js +1 -0
  16. package/dist/dqs.d.ts +42 -0
  17. package/dist/dqs.js +29 -0
  18. package/dist/errors-t1ewumJS.js +1 -0
  19. package/dist/geometry-cache.d.ts +208 -0
  20. package/dist/geometry-cache.js +4 -0
  21. package/dist/gltf-C2HVNxzB.js +1 -0
  22. package/dist/gltf.d.ts +63 -0
  23. package/dist/group.d.ts +97 -0
  24. package/dist/hdr-format-cmvLFubB.js +1 -0
  25. package/dist/index.d.ts +203 -0
  26. package/dist/index.js +1 -0
  27. package/dist/instanced-morph.d.ts +82 -0
  28. package/dist/instanced-morph.js +13 -0
  29. package/dist/instanced-skin.d.ts +82 -0
  30. package/dist/instanced-skin.js +43 -0
  31. package/dist/interactivity.d.ts +71 -0
  32. package/dist/interactivity.js +4 -0
  33. package/dist/key-cursor.d.ts +23 -0
  34. package/dist/keyframes-YpidiYS4.js +4 -0
  35. package/dist/keyframes.d.ts +204 -0
  36. package/dist/lod.d.ts +87 -0
  37. package/dist/lod.js +4 -0
  38. package/dist/material-animation.d.ts +29 -0
  39. package/dist/mixer.d.ts +226 -0
  40. package/dist/mixer.js +4 -0
  41. package/dist/morph-gpu.d.ts +94 -0
  42. package/dist/morph-gpu.js +50 -0
  43. package/dist/morph-table.d.ts +29 -0
  44. package/dist/playback.d.ts +94 -0
  45. package/dist/playback.js +4 -0
  46. package/dist/point-cache.d.ts +28 -0
  47. package/dist/point-cache.js +1 -0
  48. package/dist/pointer-DyWpFsQi.js +1 -0
  49. package/dist/pointer.d.ts +43 -0
  50. package/dist/pointer.js +1 -0
  51. package/dist/pose-source-MuCl8VDd.js +1 -0
  52. package/dist/pose.d.ts +12 -0
  53. package/dist/require-webgpu-Jrqt3Xy4.js +1 -0
  54. package/dist/retarget.d.ts +115 -0
  55. package/dist/rigid.d.ts +42 -0
  56. package/dist/sampling-DjDWYqt2.js +1 -0
  57. package/dist/sampling.d.ts +112 -0
  58. package/dist/sampling.js +1 -0
  59. package/dist/shader-DuGkHFKx.js +73 -0
  60. package/dist/shader.d.ts +62 -0
  61. package/dist/skeleton-utils.d.ts +2 -0
  62. package/dist/skeleton-utils.js +4 -0
  63. package/dist/skin.d.ts +163 -0
  64. package/dist/src-fuuIJ3rU.js +4 -0
  65. package/dist/vat-SpfL7y9U.js +53 -0
  66. package/dist/vat.d.ts +194 -0
  67. package/dist/vat.js +1 -0
  68. package/dist/vertex-map-BC_WH7ER.js +1 -0
  69. package/dist/weight-buffer.d.ts +1 -0
  70. package/package.json +139 -4
@@ -0,0 +1,53 @@
1
+ // @margo/core-built 1.0.0
2
+ import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
+
4
+ import{t as e}from"./errors-t1ewumJS.js";import{t}from"./vertex-map-BC_WH7ER.js";import{t as n}from"./require-webgpu-Jrqt3Xy4.js";import{n as r,t as i}from"./hdr-format-cmvLFubB.js";import{MargoError as a}from"@margoengine/math/errors";import{invertMatrixStable as o,multiplyMatrices as s}from"@margoengine/math/mat4";var c=`fn pbrNeutral(input:vec3f)->vec3f {let x=min(input.r,min(input.g,input.b));let offset=select(0.04,x-6.25*x*x,x<0.08);var v=input-offset;let peak=max(v.r,max(v.g,v.b));if(peak<0.76){return v;}let newPeak=1.0-0.24*0.24/(peak+0.24-0.76);v*=newPeak/peak;return mix(v,vec3f(newPeak),1.0-1.0/(0.15*(peak-newPeak)+1.0));}
5
+ `;`${c}`;var l=/* @__PURE__ */ new WeakMap;function u(e,t){let n=l.get(t),r=n?.get(e);return r===void 0?m(e,t,n):r}var d=/mix\(vec3f\(0\.35,0\.3,0\.25\),vec3f\(1(?:\.0)?\),clamp\(([\w.]+)\.y\*0\.5\+0\.5,0\.0,1\.0\)\)/g,f=e=>e.replace(d,`margoSkyHook($1)`).replaceAll(`*f.radiance.w`,``),p=e=>e!==void 0&&new RegExp(d.source).test(e);function m(t,n,r){let i=e=>e&&(t.includes(` f0:vec3f`)?e:e.replaceAll(`s.f0`,`vec3f(0.04)`)).replaceAll(`s.sw`,t.includes(` sw:f32`)?`s.sw`:`1.0`),a=t,o=(t,n)=>{if(typeof t==`string`?!a.includes(t):a.search(t)<0)throw e(`unsupported`,`PBR lighting hook point missing: ${t}; use matching @margoengine/gltf/pbr and effect package versions`);a=a.replace(t,n)},s=t.includes(`fn margoAmbientLayers(`);if(n.direct){let e=n.direct(`direct`,t.includes(`fn margoLightSide(`)?`margoLightSide(s.n,l)`:void 0);if(t.includes(`var<private> margoDirectVisible:vec3f=vec3f(1);`)&&e!==`direct`){let n=t.includes(`fn margoLit(`)?`margoLit(s,l,direct)`:`vec3f(1)`;o(/(?:let margoAmbient=[^;]*;)?var color=/,t=>`{let direct=${n};margoDirectVisible=${e};}\n ${t}`),o(`direct+ambient(s)`,`direct*margoDirectVisible+ambient(s)`)}else o(`direct+ambient(s)`,e+`+ambient(s)`)}if(n.light){if(s){let e=a.split(`fn margoLocal`).length-1;o(`var color=`,`var color=margoLocal${e}(i,margoFront(s),v)+`),a+=`\nfn margoLocal${e}(i:Out,s:Surface,v:vec3f)->vec3f {return ${i(n.light)};}\n`}else o(`var color=`,`var color=`+i(n.light)+`+`)}let c=a.includes(`fn margoSkyHook(`);n.ambient&&((!c||p(n.ambient))&&o(/fn ambient\(s:Surface\)->vec3f \{[^}]*\}/,`fn ambient(s:Surface)->vec3f {return vec3f(0);}`),s&&o(`fn margoAmbientTerm(i:Out,s:Surface,v:vec3f)->vec3f {return vec3f(0);}`,()=>`fn margoAmbientTerm(i:Out,s:Surface,v:vec3f)->vec3f {return ${i(n.ambient)};}`),o(/var color=([^;]+)\+s\.emissive;/,(e,t)=>`let margoAmbient=${s?`margoAmbientLayers(i,s,v)`:i(n.ambient)};var color=${t}+s.emissive+margoAmbient;`));for(let[e,t]of[[`margoCoatAmbient`,n.coat],[`margoSheenAmbient`,n.sheen]])t&&a.includes(`fn ${e}(`)&&o(RegExp(`fn ${e}\\(s:Surface,v:vec3f\\)->vec3f \\{return [^;]*;\\}`),()=>`fn ${e}(s:Surface,v:vec3f)->vec3f {return ${t};}`);if(n.sky){if(c)throw e(`unsupported`,`Two sky lighting hooks on one shader; attach one HemisphereLight per engine`);let t=/let margoAmbient=([^;]*);/.exec(a)?.[1],r=/fn margoAmbientTerm\(i:Out,s:Surface,v:vec3f\)->vec3f \{return ([^;]*);\}/.exec(a)?.[1];t!==void 0&&!p(t)&&!p(r)&&o(`fn ambient(s:Surface)->vec3f {return vec3f(0);}`,`fn ambient(s:Surface)->vec3f {${a.includes(`fn margoHemisphere(`)?`return margoHemisphere(s);`:a.includes(`fn hemisphere_ambient(`)?`return hemisphere_ambient(s);`:`let f0=mix(vec3f(0.04),s.base.rgb,s.metal);return (s.base.rgb*(1.0-s.metal)+f0*0.5)*margoSkyHook(s.n)*s.occlusion;`}}`),a+=`
6
+ fn margoSkyHook(n:vec3f)->vec3f {return ${n.sky};}
7
+ `}(n.sky||c)&&(a=f(a));let u=`if(f.settings.w<0.5) {color=toDisplay(color);}`;if(n.output){let e=a.includes(u);o(e?u:`if(f.settings.w<0.5) {color=pbrNeutral(max(color,vec3f(0)));`,`color=${n.output(`select(color,pbrNeutral(max(color,vec3f(0))),f.settings.w<0.5)`)};if(f.settings.w<0.5) {${e?`color=select(color*12.92,1.055*pow(color,vec3f(1.0/2.4))-0.055,color>=vec3f(0.0031308));}`:``}`)}return a=n.declarations+a,n.finish&&(a=n.finish(a)),r||l.set(n,r=/* @__PURE__ */ new Map),r.size>=64&&r.clear(),r.set(t,a),a}var h=(e,t)=>`a2/(3.14159265*pow(max(dot(cross(${e},${t}),cross(${e},${t})),step(nh,0.0))+a2*nh*nh,2.0))`,g=`2.0*nl*nv/max(nl*sqrt(a2+(1.0-a2)*nv*nv)+nv*sqrt(a2+(1.0-a2)*nl*nl),1e-30)`;function _(e,t,n){let r=Math.hypot(n[0],n[1],n[2]);e[t]=n[0]/r,e[t+1]=n[1]/r,e[t+2]=n[2]/r,e[t+3]=n[3]}var v=2048;function y(e,t,n,r,i=v){let a=(e*r+t)*2+n;return[a%i,Math.floor(a/i)]}function b(e,{fps:n=30,clips:r}={}){let i=e.model,a=i.asset.doc,c=i.root.engine.store,l=i.asset,u=(r??e.clips.map((e,t)=>t)).map(t=>typeof t==`string`?e.clips.findIndex(e=>e.name===t):t);if(!(n>0&&n<=1e3)||!u.length||u.some(t=>!e.clips[t]))throw RangeError(`Invalid VAT fps or clips; pass fps in (0, 1000] and clip indices that exist in animation.clips`);let d=i.primitives.map(e=>{let n=e.definition,r=a.nodes[e.nodeIndex].skin===void 0?null:a.skins[a.nodes[e.nodeIndex].skin],i=r?.joints??[],o=e.part?.vertexMap;return{p:e,count:e.vertices.length/20,joints:i,deltas:(n.targets??[]).map(e=>[e.POSITION,e.NORMAL].map(e=>e===void 0?null:t(l.accessor(e,`VEC3`),3,o))),bind:r?.inverseBindMatrices===void 0?new Float32Array(i.length*16).map((e,t)=>+(t%16%5==0)):l.accessor(r.inverseBindMatrices,`MAT4`),ids:r?t(l.accessor(n.attributes.JOINTS_0,`VEC4`),4,o):null,weights:r?t(l.accessor(n.attributes.WEIGHTS_0,`VEC4`),4,o):null,palette:new Float32Array(Math.max(1,i.length)*16)}}),f=d.reduce((e,t)=>e+t.count,0),p=u.map(t=>Math.max(1,Math.ceil(e.clips[t].duration*n))),m=p.reduce((e,t)=>e+t+1,0),h=Math.ceil(m*f*2/v);if(h>8192)throw RangeError(`VAT data exceeds 8192 texture rows; bake fewer clips, a lower fps or a lighter mesh`);let g=new Float32Array(v*h*4),_=new Float32Array(f*2),y=[];for(let e=0,t=0;e<d.length;t+=d[e++].count){let n=d[e].p.vertices;for(let r=0;r<d[e].count;r++)_[(t+r)*2]=n[r*20+12],_[(t+r)*2+1]=1-n[r*20+13];for(let n of d[e].p.indices)y.push(t+n)}let b={clip:e.clip,time:e.time,playing:e.playing},x=/* @__PURE__ */ new Float32Array(16),S=/* @__PURE__ */ new Float32Array(16),C=/* @__PURE__ */ new Float64Array(12),w=/* @__PURE__ */ new Float64Array(52),T=0;try{u.forEach((t,n)=>{let r=e.clips[t].duration;e.play(t);for(let t=0;t<=p[n];t++,T++){if(e.seek(r*t/p[n]),c.tick(!1),!o(i.root.matrix,x,w))throw RangeError(`Singular VAT model root; give the model root a non-zero scale before baking`);let a=T*f*8;for(let e of d){let{p:t,joints:n,palette:r,ids:o,weights:c}=e,l=t.vertices;if(n.length)for(let t=0;t<n.length;t++)s(i.nodes[n[t]].matrix,e.bind.subarray(t*16,t*16+16),S),s(x,S,r.subarray(t*16,t*16+16));else s(x,t.node.matrix,r);for(let n=0;n<e.count;n++,a+=8){let i=l[n*20],s=l[n*20+1],u=l[n*20+2],d=l[n*20+4],f=l[n*20+5],p=l[n*20+6];for(let r=0;r<e.deltas.length;r++){let[a,o]=e.deltas[r],c=t.weights[r];a&&(i+=a[n*3]*c,s+=a[n*3+1]*c,u+=a[n*3+2]*c),o&&(d+=o[n*3]*c,f+=o[n*3+1]*c,p+=o[n*3+2]*c)}if(o){C.fill(0);let e=c[n*4]+c[n*4+1]+c[n*4+2]+c[n*4+3];for(let t=0;t<4;t++){let i=o[n*4+t]*16,a=c[n*4+t]/e;for(let e=0;e<12;e++)C[e]+=r[i+e+(e/3|0)]*a}}else for(let e=0;e<12;e++)C[e]=r[e+(e/3|0)];let m=C[0]*i+C[3]*s+C[6]*u+C[9],h=C[1]*i+C[4]*s+C[7]*u+C[10],_=C[2]*i+C[5]*s+C[8]*u+C[11],v=C[4]*C[8]-C[5]*C[7],y=C[5]*C[6]-C[3]*C[8],b=C[3]*C[7]-C[4]*C[6],x=C[7]*C[2]-C[8]*C[1],S=C[8]*C[0]-C[6]*C[2],w=C[6]*C[1]-C[7]*C[0],T=C[1]*C[5]-C[2]*C[4],E=C[2]*C[3]-C[0]*C[5],D=C[0]*C[4]-C[1]*C[3],O=C[0]*v+C[1]*y+C[2]*b<0?-1:1,k=(v*d+x*f+T*p)*O,A=(y*d+S*f+E*p)*O,j=(b*d+w*f+D*p)*O,M=Math.hypot(k,A,j);g[a]=m,g[a+1]=h,g[a+2]=_,g[a+3]=1,g[a+4]=M>0?k/M:0,g[a+5]=M>0?A/M:1,g[a+6]=M>0?j/M:0}}}})}finally{e.play(b.clip),e.seek(b.time),e.playing=b.playing,c.tick(!1)}for(let e=0;e<m*f*8;e++)if(!Number.isFinite(g[e]))throw RangeError(`VAT bake produced non-finite vertices (check skin weights)`);let E=0;return{vertexCount:f,rows:m,width:v,texels:g,indices:Uint32Array.from(y),uvs:_,clips:u.map((t,n)=>{let r={name:e.clips[t].name,start:E,frames:p[n],duration:e.clips[t].duration,loop:e.options.loop??!0};return E+=p[n]+1,r})}}var x=24,S=`
8
+ struct Frame {camera:mat4x4f,eye:vec4f,light:vec4f,radiance:vec4f,base:vec4f,options:vec4f,vat:vec4f}
9
+ struct Instance {m:mat4x4f,p:vec4f,uv:vec4f}
10
+ @group(0) @binding(0) var<uniform> f:Frame;
11
+ @group(0) @binding(1) var<storage,read> instances:array<Instance>;
12
+ @group(0) @binding(2) var<storage,read> clips:array<vec4f>;
13
+ @group(0) @binding(3) var vat:texture_2d<f32>;
14
+ @group(0) @binding(4) var map:texture_2d<f32>;
15
+ @group(0) @binding(5) var mapSampler:sampler;
16
+ struct Out {@builtin(position) @invariant clip:vec4f,@location(0) position:vec3f,@location(1) normal:vec3f,@location(2) uv:vec2f}
17
+ fn texel(row:u32,v:u32,k:u32)->vec4f {let i=(row*u32(f.vat.x)+v)*2u+k;let w=u32(f.vat.y);return textureLoad(vat,vec2u(i%w,i/w),0);}
18
+ @vertex fn vertex(@location(0) uv:vec2f,@builtin(vertex_index) v:u32,@builtin(instance_index) id:u32)->Out {
19
+ let s=instances[id];let c=clips[u32(s.p.x)];var t=(f.options.x*s.p.z+s.p.y)/max(c.z,0.000001);
20
+ t=select(clamp(t,0.0,1.0),fract(t),c.w>0.5);let x=t*c.y;let a=min(floor(x),c.y-1.0);let w=x-a;let r=u32(c.x+a);
21
+ let p=mix(texel(r,v,0u),texel(r+1u,v,0u),w).xyz;let n=mix(texel(r,v,1u),texel(r+1u,v,1u),w).xyz;
22
+ let m=s.m;let c0=cross(m[1].xyz,m[2].xyz);let world=m*vec4f(p,1.0);
23
+ var o:Out;o.clip=f.camera*world;o.position=world.xyz;let bent=mat3x3f(c0,cross(m[2].xyz,m[0].xyz),cross(m[0].xyz,m[1].xyz))*n*select(-1.0,1.0,dot(m[0].xyz,c0)>=0.0);o.normal=select(vec3f(0,1,0),bent,dot(bent,bent)>0.0);o.uv=s.uv.xy+uv*s.uv.zw;return o;
24
+ }
25
+ `,C=`fn srgb(c:vec3f)->vec3f {let x=clamp(c,vec3f(0.0),vec3f(1.0));return select(x*12.92,1.055*pow(x,vec3f(1.0/2.4))-0.055,x>=vec3f(0.0031308));}
26
+ `,w=e=>`${c}${e}${C}
27
+ @fragment fn fragment(i:Out,@builtin(front_facing) front:bool)->@location(0) vec4f {
28
+ let albedo=(f.base*textureSample(map,mapSampler,i.uv)).rgb;let rough=f.options.z;let metal=f.options.w;
29
+ let nn=normalize(i.normal)*select(-1.0,1.0,front);let v=normalize(f.eye.xyz-i.position);let l=f.light.xyz;let h=(v+l)/max(length(v+l),0.0001);
30
+ let nl=clamp(dot(nn,l),0.0,1.0);let nv=clamp(dot(nn,v),0.0001,1.0);let nh=clamp(dot(nn,h),0.0,1.0);let vh=clamp(dot(v,h),0.0,1.0);
31
+ let a=rough*rough;let a2=a*a;let d=${/* @__PURE__ */ h(`nn`,`h`)};let g=${g};
32
+ let f0=mix(vec3f(0.04),albedo,metal);let fresnel=f0+(1.0-f0)*pow(1.0-vh,5.0);
33
+ var color=((1.0-(0.04+0.96*pow(1.0-vh,5.0)))*(1.0-metal)*albedo/3.14159265+d*g*fresnel/max(4.0*nl*nv,0.0001))*nl*f.radiance.rgb*f.light.w
34
+ +(albedo*(1.0-metal)+f0*0.5)*mix(vec3f(0.35,0.3,0.25),vec3f(1.0),clamp(nn.y*0.5+0.5,0.0,1.0))*f.radiance.w;
35
+ if(f.vat.z<0.5){color=srgb(pbrNeutral(max(color,vec3f(0.0))));}
36
+ return vec4f(color,1.0);
37
+ }`,T=w(S),E=/* @__PURE__ */ new Map,D=e=>`${c}${e.replace(`vat:vec4f}`,`settings:vec4f}`).replaceAll(`f.vat.`,`f.settings.`)}${C}
38
+ struct Surface {base:vec4f,n:vec3f,roughness:f32,metal:f32,occlusion:f32,emissive:vec3f}
39
+ fn ambient(s:Surface)->vec3f {let f0=mix(vec3f(0.04),s.base.rgb,s.metal);return (s.base.rgb*(1.0-s.metal)+f0*0.5)*mix(vec3f(0.35,0.3,0.25),vec3f(1.0),clamp(s.n.y*0.5+0.5,0.0,1.0))*f.radiance.w*s.occlusion;}
40
+ @fragment fn fragment(i:Out,@builtin(front_facing) front:bool)->@location(0) vec4f {
41
+ var s:Surface;s.base=f.base*textureSample(map,mapSampler,i.uv);s.n=normalize(i.normal)*select(-1.0,1.0,front);s.roughness=f.options.z;s.metal=f.options.w;s.occlusion=1.0;
42
+ let v=normalize(f.eye.xyz-i.position);let l=f.light.xyz;let h=(v+l)/max(length(v+l),0.0001);
43
+ let nl=clamp(dot(s.n,l),0.0,1.0);let nv=clamp(dot(s.n,v),0.0001,1.0);let nh=clamp(dot(s.n,h),0.0,1.0);let vh=clamp(dot(v,h),0.0,1.0);
44
+ let a=s.roughness*s.roughness;let a2=a*a;let d=${/* @__PURE__ */ h(`s.n`,`h`)};let g=${g};
45
+ let f0=mix(vec3f(0.04),s.base.rgb,s.metal);let fresnel=f0+(1.0-f0)*pow(1.0-vh,5.0);
46
+ let direct=((1.0-(0.04+0.96*pow(1.0-vh,5.0)))*(1.0-s.metal)*s.base.rgb/3.14159265+d*g*fresnel/max(4.0*nl*nv,0.0001))*nl*f.radiance.rgb*f.light.w;
47
+ var color=direct+ambient(s)+s.emissive;
48
+ if(f.settings.w<0.5) {color=pbrNeutral(max(color,vec3f(0))); color=srgb(color);}
49
+ return vec4f(color,1.0);
50
+ }`;function O(e){let t=E.get(e);return t||E.set(e,t=D(e)),t}var k=/* @__PURE__ */ new Map;function A(e){let t=k.get(e);if(t)return t;let n=`@fragment fn fragment(i:Out,@builtin(front_facing) front:bool)->@location(0) vec4f {`,r=`return vec4f(color,1.0);
51
+ }`,i=e.includes(`let margoAmbient=`)?`ambient(s)+margoAmbient`:`ambient(s)`;if(!e.includes(n)||!e.includes(r))throw new a(`unsupported`,`VAT crowd SSAO: a lighting effect replaced the crowd fragment; use matching package versions`);return t=e.replace(n,`struct MargoOcclusionOut {@location(0) normal:vec4f,@location(1) ambient:vec4f}
52
+ @group(2) @binding(0) var<uniform> occlusionView:mat4x4f;
53
+ `+n.replace(`@location(0) vec4f`,`MargoOcclusionOut`)).replace(r,`return MargoOcclusionOut(vec4f(normalize((occlusionView*vec4f(s.n,0.0)).xyz),-(occlusionView*vec4f(i.position,1.0)).z),vec4f(${i},1.0));\n}`),k.size>=64&&k.clear(),k.set(e,t),t}var j=0,M=class e{coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);static attach(t,n,r){__margoAssertCore(t,__margoCoreRequirement("1.0.0",import.meta.url));let i=new e(n,r);return t.use(i),i}constructor(e,{color:t=[1,1,1,1],map:n=null,roughness:r=.6,metalness:i=0}={},a={vertex:S,stride:24,rowSize:e?.vertexCount,vertices:[],attributes:[]}){if(this.vat=e,this.layout=a,this.name=`vat:`+j++,this.time=0,this.disposed=!1,this.n=0,this.dirty=!0,this.key=``,this.bound=[],this.frame=/* @__PURE__ */ new Float32Array(40),this.lighting=/* @__PURE__ */ new Set,!(e?.texels instanceof Float32Array)||!e.clips?.length||t.length!==4||!(r>=0&&r<=1&&i>=0&&i<=1))throw TypeError(`Invalid VAT crowd; pass baked VAT data with clips, a 4-number color, and roughness and metalness in 0..1`);this.color=[...t],this.roughness=r,this.metalness=i,this.map=n,this.data=new Float32Array(a.stride*16),this.plain=this.code=a.vertex===S?T:w(a.vertex)}get rows(){return this.data}get count(){return this.n}add(e={}){let t=this.layout.stride;if(this.n*t===this.data.length){let e=new Float32Array(this.data.length*2);e.set(this.data),this.data=e}this.data.fill(0,this.n*t,(this.n+1)*t),this.data.set([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1],this.n*t),t>24&&(this.data[this.n*t+24+2]=1),this.n++;try{this.set(this.n-1,e)}catch(e){throw this.n--,e}return this.n-1}set(e,{matrix:t,clip:n,offset:r,speed:i,uvTransform:a}){if(!(Number.isInteger(e)&&e>=0&&e<this.n)||n!==void 0&&!(Number.isInteger(n)&&n>=0&&n<this.vat.clips.length)||t!==void 0&&t.length!==16)throw RangeError(`Invalid VAT instance; use an index below the instance count, a clip from vat.clips, a 16-number matrix and finite values`);let o=this.layout.stride,s=e*o,c=this.data;t&&c.set(t,s),n!==void 0&&(c[s+16]=n),r!==void 0&&(c[s+17]=r),i!==void 0&&(c[s+18]=i),a&&(c.set(a.offset??[0,0],s+20),c.set(a.scale??[1,1],s+22));for(let e=s;e<s+o;e++)if(!Number.isFinite(c[e]))throw RangeError(`Invalid VAT instance; use an index below the instance count, a clip from vat.clips, a 16-number matrix and finite values`);return this.dirty=!0,this}truncate(e){if(!(Number.isInteger(e)&&e>=0&&e<=this.n))throw RangeError(`Invalid VAT count; truncate to an integer from 0 to the current count`);this.n=e}setup(e){if(this.disposed)throw new a(`disposed`,`VATCrowd is disposed; create a new crowd before attaching`);n(e,`VATCrowd`),this.engine=e}onPreUpdate(e){this.advanceTime(e)}advanceTime(e){if(!Number.isFinite(e)||e<0)throw RangeError(`Invalid VAT delta; pass finite seconds >= 0`);this.disposed||(this.time+=e)}registerPasses(e){e.add({name:this.name,order:1,execute:e=>{e.backend===`webgpu`&&this.drawBeauty(e)}})}resources(e){if(this.device===e&&this.gpu)return this.gpu;this.release(),this.device=e;let t=this.vat,n=(t,n)=>{let r=e.createBuffer({size:Math.max(16,t.byteLength),usage:n|GPUBufferUsage.COPY_DST});return e.queue.writeBuffer(r,0,t),r},r=e.createTexture({size:[t.width,t.texels.length/t.width/4],format:`rgba32float`,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST});e.queue.writeTexture({texture:r},t.texels,{bytesPerRow:t.width*16},[t.width,t.texels.length/t.width/4]);let i=e.createTexture({size:[1,1],format:`rgba8unorm`,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST});return e.queue.writeTexture({texture:i},new Uint8Array([255,255,255,255]),{bytesPerRow:4},[1,1]),this.gpu={vat:r,white:i,blank:[i.createView(),e.createSampler()],uvs:n(t.uvs,GPUBufferUsage.VERTEX),vertices:this.layout.vertices.map(e=>n(e,GPUBufferUsage.VERTEX)),index:n(t.indices,GPUBufferUsage.INDEX),frame:e.createBuffer({size:160,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),clips:n(Float32Array.from(t.clips.flatMap(e=>[e.start,e.frames,e.duration,+e.loop])),GPUBufferUsage.STORAGE)}}addLighting(e){if(this.disposed||!e||typeof e.pbr!=`function`||typeof e.bindings!=`function`)throw TypeError(`VAT crowd lighting needs a live crowd and an effect with pbr() and bindings() functions`);if(e.owner&&this.engine&&e.owner!==this.engine)throw new a(`attached`,`VAT lighting belongs to another engine; use an effect created on the crowd's engine`);return this.lighting.add(e),()=>{this.lighting.delete(e)}}drawShadow({context:e,pass:t,matrix:n,cascade:r}){if(!this.n||!this.engine)return;let i=e.device,a=this.upload(i),o=this.shadow;if(!o){let e=i.createShaderModule({code:this.layout.vertex});o=this.shadow={pipeline:i.createRenderPipeline({layout:`auto`,vertex:{module:e,entryPoint:`vertex`,buffers:this.vertexLayout()},depthStencil:{format:`depth32float`,depthWriteEnabled:!0,depthCompare:`less-equal`}}),frames:i.createBuffer({size:1024,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),groups:[],values:/* @__PURE__ */ new Float32Array(40)}}if(o.instances!==a.instances){o.instances=a.instances;let e=a.vat.createView();o.groups=[0,1,2,3].map(t=>i.createBindGroup({layout:o.pipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:o.frames,offset:t*256,size:160}},{binding:1,resource:{buffer:a.instances}},{binding:2,resource:{buffer:a.clips}},{binding:3,resource:e}]}))}let s=o.values;s.set(n),s[32]=this.time,s[36]=this.layout.rowSize,s[37]=this.vat.width,i.queue.writeBuffer(o.frames,r*256,s),t.setPipeline(o.pipeline),t.setBindGroup(0,o.groups[r]),this.bindVertices(t,a),t.setIndexBuffer(a.index,`uint32`),t.drawIndexed(this.vat.indices.length,this.n)}vertexLayout(){return[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:`float32x2`}]},...this.layout.attributes]}bindVertices(e,t){e.setVertexBuffer(0,t.uvs),t.vertices.forEach((t,n)=>e.setVertexBuffer(n+1,t))}upload(e){let t=this.resources(e),n=this.layout.stride;return(!t.instances||t.instances.size<this.n*n*4)&&(t.instances?.destroy(),t.instances=e.createBuffer({size:this.data.byteLength,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),this.dirty=!0),this.dirty&&=(e.queue.writeBuffer(t.instances,0,this.data,0,this.n*n),!1),t}composed(e){let t=e?O(this.layout.vertex):this.plain,n=[];for(let e of this.lighting){let r=e.pbr(1);r&&(t=u(t===this.plain?O(this.layout.vertex):t,r),n.push(...e.bindings()))}return{code:t,entries:n}}draw(e,t,n,r,i,a){if(t!==`occlusion`||!a||!this.n||!this.engine||this.disposed)return;let o=e.device,s=this.upload(o),{code:c,entries:l}=this.composed(!0),u=A(c),d=e.descriptor.multisample?.count??1,f=e.descriptor.depthStencil.format,p=`${d}${f}${a.depthCompare}`,m=this.occlusion;if(!m||m.key!==p||m.code!==u){let e=o.createShaderModule({code:u});m?.view.destroy();let t=o.createRenderPipeline({layout:`auto`,vertex:{module:e,entryPoint:`vertex`,buffers:this.vertexLayout()},fragment:{module:e,entryPoint:`fragment`,targets:[{format:`rgba16float`},{format:`rgba16float`}]},primitive:{cullMode:`back`},depthStencil:{format:f,depthWriteEnabled:!1,depthCompare:a.depthCompare},multisample:{count:d}}),n=o.createBuffer({size:64,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});m=this.occlusion={key:p,code:u,pipeline:t,view:n,viewGroup:o.createBindGroup({layout:t.getBindGroupLayout(2),entries:[{binding:0,resource:{buffer:n}}]}),values:/* @__PURE__ */ new Float32Array(16),groups:[],bound:[]}}m.values.set(a.view),o.queue.writeBuffer(m.view,0,m.values);let[h,g]=this.map?.bind(o,!0)??s.blank,_=[s.instances,h,g,...l.map(e=>`buffer`in e.resource?e.resource.buffer:e.resource)];if(!m.groups.length||_.length!==m.bound.length||_.some((e,t)=>e!==m.bound[t])){let e=e=>m.pipeline.getBindGroupLayout(e);m.bound=_,m.groups=[o.createBindGroup({layout:e(0),entries:[s.frame,s.instances,s.clips].map((e,t)=>({binding:t,resource:{buffer:e}})).concat({binding:3,resource:s.vat.createView()},{binding:4,resource:h},{binding:5,resource:g})}),...l.length?[o.createBindGroup({layout:e(1),entries:l})]:[]]}let v=a.pass;v.setPipeline(m.pipeline),v.setBindGroup(0,m.groups[0]),l.length&&v.setBindGroup(1,m.groups[1]),v.setBindGroup(2,m.viewGroup),this.bindVertices(v,s),v.setIndexBuffer(s.index,`uint32`),v.drawIndexed(this.vat.indices.length,this.n)}drawBeauty(e){let t=this.engine;if(!this.n||!t)return;let n=e.device,a=this.upload(n),o=e.descriptor.multisample?.count??1,s=e.descriptor.depthStencil.format,{code:c,entries:l}=this.composed(!1),u=this.frame;u.set(e.camera.matrix),u.set(e.camera.position,16),_(u,20,t.lighting.direction),u.set(t.lighting.radiance,24),u.set(this.color,28),u[32]=this.time,u[34]=Math.min(1,Math.max(.045,this.roughness)),u[35]=this.metalness,u[36]=this.layout.rowSize,u[37]=this.vat.width,u[38]=+i(e.format),u[39]=c===this.plain?0:u[38],n.queue.writeBuffer(a.frame,0,u);let d=e.format+o+s;if(this.key!==d||this.code!==c){let t=n.createShaderModule({code:c});this.key=d,this.code=c,this.pipeline=n.createRenderPipeline({layout:`auto`,vertex:{module:t,entryPoint:`vertex`,buffers:this.vertexLayout()},fragment:{module:t,entryPoint:`fragment`,targets:[{format:e.format}]},primitive:{cullMode:`back`},depthStencil:{format:s,depthWriteEnabled:!0,depthCompare:`greater-equal`},multisample:{count:o}})}let[f,p]=this.map?.bind(n,!0)??a.blank,m=[this.pipeline,a.instances,f,p];(!this.group||m.some((e,t)=>e!==this.bound[t]))&&(this.bound=m,this.group=n.createBindGroup({layout:this.pipeline.getBindGroupLayout(0),entries:[a.frame,a.instances,a.clips].map((e,t)=>({binding:t,resource:{buffer:e}})).concat({binding:3,resource:a.vat.createView()},{binding:4,resource:f},{binding:5,resource:p})}));let h=e.encoder.beginRenderPass({colorAttachments:[{view:e.color,loadOp:`load`,storeOp:`store`}],depthStencilAttachment:{view:e.depth,depthLoadOp:`load`,depthStoreOp:`store`,stencilReadOnly:!0}});if(r(h,e),h.setPipeline(this.pipeline),h.setBindGroup(0,this.group),l.length){let e=[this.pipeline,...l.map(e=>`buffer`in e.resource?e.resource.buffer:e.resource)];(!this.light||e.length!==this.light.bound.length||e.some((e,t)=>e!==this.light.bound[t]))&&(this.light={bound:e,group:n.createBindGroup({layout:this.pipeline.getBindGroupLayout(1),entries:l})}),h.setBindGroup(1,this.light.group)}this.bindVertices(h,a),h.setIndexBuffer(a.index,`uint32`),h.drawIndexed(this.vat.indices.length,this.n),h.end(),t.stats.drawCalls++,t.stats.visible+=this.n}release(){let e=this.gpu;if(e)for(let t of[e.vat,e.white,e.uvs,...e.vertices,e.index,e.frame,e.clips,e.instances,this.shadow?.frames,this.occlusion?.view])t?.destroy();this.gpu=this.pipeline=this.group=this.light=this.shadow=this.occlusion=void 0,this.key=``,this.code=this.plain,this.bound=[],this.device=void 0}onDeviceRestored(){this.release(),this.dirty=!0}dispose(){this.disposed||(this.disposed=!0,this.engine?.sceneOf(this)?.removePlugin(this.name),this.lighting.clear(),this.release(),this.engine=void 0)}[Symbol.dispose??Symbol()](){this.dispose()}};export{T as a,b as i,x as n,y as o,v as r,M as t};
package/dist/vat.d.ts ADDED
@@ -0,0 +1,194 @@
1
+ /// <reference lib="esnext.disposable" preserve="true" />
2
+ import type { EngineKernel } from '@margoengine/core';
3
+ import type { Engine, EnginePlugin, FrameGraph, PassContext } from '@margoengine/core/extension';
4
+ import type { Animation } from './index.js';
5
+ type Context = Extract<PassContext, {
6
+ backend: 'webgpu';
7
+ }>;
8
+ /** Rows `start`..`start + frames` hold the clip at `duration * row / frames`; a looping clip's last row equals its first. */
9
+ export interface VATClip {
10
+ name: string;
11
+ start: number;
12
+ frames: number;
13
+ duration: number;
14
+ loop: boolean;
15
+ }
16
+ /** Baked vertex animation: per row and vertex two rgba32float texels (model-root-space position, normal), wrapped at `width`. */
17
+ export interface VATData {
18
+ vertexCount: number;
19
+ rows: number;
20
+ width: number;
21
+ texels: Float32Array;
22
+ indices: Uint32Array;
23
+ /** UV0 with v up, like `@margoengine/materials` textures. */
24
+ uvs: Float32Array;
25
+ clips: VATClip[];
26
+ }
27
+ /** Options for {@link bakeVAT}. */
28
+ export interface VATBakeOptions {
29
+ /** Rows per second. Default 30. */ fps?: number;
30
+ /** Clip names or indices. Default: all. */
31
+ clips?: readonly (string | number)[];
32
+ }
33
+ /** Texture width VAT data wraps at (any WebGPU device takes 8192 rows of it). */
34
+ export declare const VAT_WIDTH = 2048;
35
+ /** Texel (x, y) of a baked row's vertex: k 0 is position, 1 is normal. The shader computes the same. */
36
+ export declare function vatTexel(row: number, vertex: number, k: number, vertexCount: number, width?: number): [number, number];
37
+ /**
38
+ * Bakes clips of a skinned and/or morphed glTF (an `Animation`) on the CPU into one vertex animation texture, all
39
+ * primitives merged in the model root's space. Skinning and morphs follow the GPU deformation pass. The animation's
40
+ * clip, time and playing state are restored afterwards.
41
+ */
42
+ export declare function bakeVAT(animation: Animation, { fps, clips }?: VATBakeOptions): VATData;
43
+ /** Instance layout (24 floats): world matrix, then clip, time offset (s), speed, 0, then UV offset.xy and scale.xy. */
44
+ export declare const VAT_STRIDE = 24;
45
+ /** One crowd member for {@link VATCrowd.add} and {@link VATCrowd.set}. */
46
+ export interface VATInstance {
47
+ /** Column-major 4x4 world matrix (16 numbers). Default identity. */
48
+ matrix?: ArrayLike<number>;
49
+ /** Index into `vat.clips`. Default 0. */
50
+ clip?: number;
51
+ /** Time offset into the clip in seconds, so crowd members do not move in step. Default 0. */
52
+ offset?: number;
53
+ /** Playback speed multiplier. Default 1. */
54
+ speed?: number;
55
+ /** Atlas region (offset and scale; no rotation). */
56
+ uvTransform?: {
57
+ offset?: readonly number[];
58
+ scale?: readonly number[];
59
+ };
60
+ }
61
+ /** Anything with `@margoengine/materials` Texture's `bind`. */
62
+ export interface VATMap {
63
+ bind(device: GPUDevice, srgb: boolean): [GPUTextureView, GPUSampler] | undefined;
64
+ }
65
+ /** Options for {@link VATCrowd}. */
66
+ export interface VATCrowdOptions {
67
+ /** Base colour, linear RGBA. Default `[1, 1, 1, 1]`. */
68
+ color?: readonly number[];
69
+ /** Base colour texture (a `@margoengine/materials` Texture). Default none. */
70
+ map?: VATMap | null;
71
+ /** Surface roughness, 0..1. Default 0.6. */
72
+ roughness?: number;
73
+ /** Metalness, 0..1. Default 0. */
74
+ metalness?: number;
75
+ }
76
+ /** @internal What a crowd of another kind changes: `@margoengine/animation/instanced-skin` draws through VATCrowd. */
77
+ export interface CrowdLayout {
78
+ /** Bindings, pose sampling and the vertex stage; location 0 is the UV. */
79
+ readonly vertex: string;
80
+ /** Floats per instance, the first 24 as {@link VAT_STRIDE}. */
81
+ readonly stride: number;
82
+ /** What the vertex stage multiplies a texture row by: vertices, or bones. */
83
+ readonly rowSize: number;
84
+ /** Vertex data after the UVs, and how the stage reads it. */
85
+ readonly vertices: readonly (Float32Array | Uint32Array)[];
86
+ readonly attributes: readonly GPUVertexBufferLayout[];
87
+ }
88
+ /** gltf/pbr's lighting hooks (its `PBRLighting`), declared here so the VAT entry does not import gltf/pbr. */
89
+ export interface VATLightingHooks {
90
+ readonly declarations: string;
91
+ direct?(direct: string): string;
92
+ readonly light?: string;
93
+ readonly ambient?: string;
94
+ output?(color: string): string;
95
+ }
96
+ /** What `crowd.addLighting` takes: an effect with gltf/pbr `pbr` hooks (Shadows, EnvironmentLighting, Fog), bound in group 1. */
97
+ export interface VATLighting {
98
+ pbr?(group: number): VATLightingHooks | undefined;
99
+ bindings(): GPUBindGroupEntry[];
100
+ readonly owner?: unknown;
101
+ }
102
+ /** The WGSL source the crowd draws with: bindings, vertex-texture pose sampling and neutral shading. Exposed for tooling and tests; {@link VATCrowd} builds its pipeline from it. */
103
+ export declare const vatShader: string;
104
+ /** What SSAO hands a source's `draw` in `'occlusion'` mode (`@margoengine/post` `SSAOSource`), declared here so the VAT entry does not import post. */
105
+ export interface VATOcclusionPass {
106
+ readonly pass: GPURenderPassEncoder;
107
+ readonly view: ArrayLike<number>;
108
+ readonly depthCompare: GPUCompareFunction;
109
+ }
110
+ /**
111
+ * Draws any number of copies of baked VAT data in one instanced call: each instance has its own matrix, clip, time
112
+ * offset, speed and atlas region, and the CPU does no per-instance work per frame (instance data uploads only when
113
+ * changed). Opaque; the GPU clips off-screen instances (no CPU culling). `shadows.add(crowd)` casts the posed crowd
114
+ * into `@margoengine/shadows` and shadows it; `lighting.add(crowd)` lights it with an EnvironmentLighting (IBL);
115
+ * `lights.add(crowd)` lights it with `@margoengine/clustered` point, spot and area lights; `ssao.add(crowd)` lets
116
+ * `@margoengine/post` SSAO darken its ambient light where it is occluded.
117
+ */
118
+ export declare class VATCrowd implements EnginePlugin {
119
+ readonly vat: VATData;
120
+ /** @internal */
121
+ private readonly layout;
122
+ readonly name: string;
123
+ /** Seconds since added; instance time is `time * speed + offset`. */
124
+ time: number;
125
+ readonly color: number[];
126
+ roughness: number;
127
+ metalness: number;
128
+ map: VATMap | null;
129
+ disposed: boolean;
130
+ private data;
131
+ private n;
132
+ /** The plain shader of this crowd's kind. */
133
+ private readonly plain;
134
+ private dirty;
135
+ private engine?;
136
+ private device?;
137
+ private gpu?;
138
+ private pipeline?;
139
+ private key;
140
+ private group?;
141
+ private bound;
142
+ private readonly frame;
143
+ private readonly lighting;
144
+ private code;
145
+ private light?;
146
+ private occlusion?;
147
+ private shadow?;
148
+ /** Same as `engine.use(new VATCrowd(...))`; returns the VATCrowd. */
149
+ static attach(engine: EngineKernel, vat: VATData, options?: VATCrowdOptions): VATCrowd;
150
+ constructor(vat: VATData, { color, map, roughness, metalness }?: VATCrowdOptions,
151
+ /** @internal */
152
+ layout?: CrowdLayout);
153
+ /** @internal This crowd's instance rows, for a kind that adds fields of its own. */
154
+ protected get rows(): Float32Array;
155
+ get count(): number;
156
+ /** Adds an instance (identity matrix, clip 0, offset 0, speed 1, whole texture by default) and returns its index. */
157
+ add(instance?: VATInstance): number;
158
+ /** Changes the given fields of one instance. */
159
+ set(index: number, { matrix, clip, offset, speed, uvTransform }: VATInstance): this;
160
+ /** Drops the last `count - n` instances. */
161
+ truncate(n: number): void;
162
+ setup(engine: Engine): void;
163
+ onPreUpdate(delta: number): void;
164
+ /** Moves `time` by `delta` seconds; the draw samples it per instance, so a seek replays it. */
165
+ advanceTime(delta: number): void;
166
+ registerPasses(graph: FrameGraph): void;
167
+ private resources;
168
+ /** Lights the crowd with an effect's gltf\/pbr `pbr` hooks; `shadows.add(crowd)` and `lighting.add(crowd)` call this. Returns a remover. */
169
+ addLighting(effect: VATLighting): () => void;
170
+ /** Shadows' per-cascade callback: the posed instances into that cascade's depth map, at the frame's crowd time. */
171
+ drawShadow({ context: c, pass, matrix, cascade, }: {
172
+ context: Context;
173
+ pass: GPURenderPassEncoder;
174
+ matrix: Float32Array;
175
+ cascade: number;
176
+ }): void;
177
+ private vertexLayout;
178
+ private bindVertices;
179
+ private upload;
180
+ /** The shader with every ready effect composed in (group 1) and their bindings; `lit` starts from the lit shader even with none. */
181
+ private composed;
182
+ /**
183
+ * `@margoengine/post` SSAO's source call (`ssao.add(crowd)`): in `'occlusion'` mode the posed crowd writes its
184
+ * view-space normal and depth and its ambient light into SSAO's open G-buffer pass, depth-tested against the depth
185
+ * the crowd drew this frame. Other modes draw nothing.
186
+ */
187
+ draw(c: Context, mode: 'gbuffer' | 'ambient' | 'occlusion', _color?: GPUTextureView, _depth?: GPUTextureView, _phase?: 'all' | 'opaque' | 'blend', external?: VATOcclusionPass): void;
188
+ private drawBeauty;
189
+ private release;
190
+ onDeviceRestored(): void;
191
+ dispose(): void;
192
+ [Symbol.dispose]: () => void;
193
+ }
194
+ export {};
package/dist/vat.js ADDED
@@ -0,0 +1 @@
1
+ export{t as VATCrowd,n as VAT_STRIDE,r as VAT_WIDTH,i as bakeVAT,a as vatShader,o as vatTexel}from"./vat-SpfL7y9U.js";
@@ -0,0 +1 @@
1
+ var e=/* @__PURE__ */ new WeakMap;function t(t,n,r){if(!r)return t;let i=e.get(r);i||e.set(r,i=/* @__PURE__ */ new WeakMap);let a=i.get(t);if(a)return a;a=new t.constructor(r.length*n);for(let e=0;e<r.length;e++){let i=r[e]*n;if(i+n>t.length)throw RangeError(`Part vertex out of range; every per-vertex accessor needs one element per vertex`);for(let r=0;r<n;r++)a[e*n+r]=t[i+r]}return i.set(t,a),a}export{t};
@@ -0,0 +1 @@
1
+ export declare function ordinaryWeightBuffer(values: Float32Array): boolean;
package/package.json CHANGED
@@ -1,6 +1,141 @@
1
1
  {
2
2
  "name": "@margoengine/animation",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Storage-buffer skinning and compute morph targets for Margo Engine.",
5
+ "keywords": [
6
+ "margoengine",
7
+ "webgpu",
8
+ "3d",
9
+ "animation"
10
+ ],
11
+ "homepage": "https://margoengine.com",
12
+ "bugs": {
13
+ "url": "https://github.com/scottcampbelldata/margoengine/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/scottcampbelldata/margoengine.git",
18
+ "directory": "packages/animation"
19
+ },
20
+ "license": "Apache-2.0",
21
+ "author": "Scott Campbell",
22
+ "type": "module",
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "scripts": {
27
+ "test": "node --test tests/*.test.js test/*.test.js ../../tests/modern-extensions.test.js ../../tests/deep-interaction-animation-resources.test.js ../../examples/package-benchmarks/proofs/package-guard.mjs",
28
+ "test:gpu": "cd ../.. && node scripts/animation-batched-deformation-tests.js",
29
+ "test:browser": "cd ../.. && node packages/animation/test/vat-clustered-browser.mjs && node packages/animation/test/vat-ssao-browser.mjs",
30
+ "test:gpu:morph": "cd ../.. && node scripts/animation-morph-gpu-tests.js",
31
+ "test:gpu:dqs": "cd ../.. && node scripts/animation-dqs-tests.js",
32
+ "test:gpu:cor": "cd ../.. && node scripts/animation-cor-tests.js",
33
+ "test:gpu:instanced-skin": "cd ../.. && node scripts/animation-instanced-skin-tests.js",
34
+ "test:gpu:geometry-cache": "cd ../.. && node scripts/animation-geometry-cache-tests.js",
35
+ "prepack": "npm --prefix ../.. run build:packages",
36
+ "test:gpu:mixer": "cd ../.. && node packages/animation/tests/mixer-browser.mjs",
37
+ "test:gpu:playback": "cd ../.. && node packages/animation/tests/playback-browser.mjs",
38
+ "test:gpu:discrete": "cd ../.. && node packages/animation/tests/discrete-browser.mjs",
39
+ "test:gpu:uploads": "cd ../.. && node packages/animation/tests/upload-copies-browser.mjs",
40
+ "test:gpu:points": "cd ../.. && node packages/animation/tests/deformed-points-browser.mjs",
41
+ "test:gpu:instanced-morph": "cd ../.. && node packages/animation/tests/instanced-morph-browser.mjs",
42
+ "test:gpu:vat-ssao": "cd ../.. && node packages/animation/test/vat-ssao-browser.mjs",
43
+ "test:gpu:vat-clustered": "cd ../.. && node packages/animation/test/vat-clustered-browser.mjs"
44
+ },
45
+ "sideEffects": false,
46
+ "exports": {
47
+ ".": {
48
+ "types": "./dist/index.d.ts",
49
+ "import": "./dist/index.js"
50
+ },
51
+ "./vat": {
52
+ "types": "./dist/vat.d.ts",
53
+ "import": "./dist/vat.js"
54
+ },
55
+ "./sampling": {
56
+ "types": "./dist/sampling.d.ts",
57
+ "import": "./dist/sampling.js"
58
+ },
59
+ "./pointer": {
60
+ "types": "./dist/pointer.d.ts",
61
+ "import": "./dist/pointer.js"
62
+ },
63
+ "./interactivity": {
64
+ "types": "./dist/interactivity.d.ts",
65
+ "import": "./dist/interactivity.js"
66
+ },
67
+ "./skeleton-utils": {
68
+ "types": "./dist/skeleton-utils.d.ts",
69
+ "import": "./dist/skeleton-utils.js"
70
+ },
71
+ "./morph-gpu": {
72
+ "types": "./dist/morph-gpu.d.ts",
73
+ "import": "./dist/morph-gpu.js"
74
+ },
75
+ "./lod": {
76
+ "types": "./dist/lod.d.ts",
77
+ "import": "./dist/lod.js"
78
+ },
79
+ "./clip-utils": {
80
+ "types": "./dist/clip-utils.d.ts",
81
+ "import": "./dist/clip-utils.js"
82
+ },
83
+ "./dqs": {
84
+ "types": "./dist/dqs.d.ts",
85
+ "import": "./dist/dqs.js"
86
+ },
87
+ "./cor": {
88
+ "types": "./dist/cor.d.ts",
89
+ "import": "./dist/cor.js"
90
+ },
91
+ "./instanced-skin": {
92
+ "types": "./dist/instanced-skin.d.ts",
93
+ "import": "./dist/instanced-skin.js"
94
+ },
95
+ "./geometry-cache": {
96
+ "types": "./dist/geometry-cache.d.ts",
97
+ "import": "./dist/geometry-cache.js"
98
+ },
99
+ "./point-cache": {
100
+ "types": "./dist/point-cache.d.ts",
101
+ "import": "./dist/point-cache.js"
102
+ },
103
+ "./mixer": {
104
+ "types": "./dist/mixer.d.ts",
105
+ "import": "./dist/mixer.js"
106
+ },
107
+ "./playback": {
108
+ "types": "./dist/playback.d.ts",
109
+ "import": "./dist/playback.js"
110
+ },
111
+ "./discrete-tracks": {
112
+ "types": "./dist/discrete-tracks.d.ts",
113
+ "import": "./dist/discrete-tracks.js"
114
+ },
115
+ "./deformed-points": {
116
+ "types": "./dist/deformed-points.d.ts",
117
+ "import": "./dist/deformed-points.js"
118
+ },
119
+ "./instanced-morph": {
120
+ "types": "./dist/instanced-morph.d.ts",
121
+ "import": "./dist/instanced-morph.js"
122
+ }
123
+ },
124
+ "files": [
125
+ "dist",
126
+ "NOTICE"
127
+ ],
128
+ "peerDependencies": {
129
+ "@margoengine/core": "^1.0.0",
130
+ "@margoengine/gltf": "^1.0.0",
131
+ "@margoengine/selection": "^1.0.0"
132
+ },
133
+ "peerDependenciesMeta": {
134
+ "@margoengine/selection": {
135
+ "optional": true
136
+ }
137
+ },
138
+ "dependencies": {
139
+ "@margoengine/math": "^1.0.0"
140
+ }
141
+ }