@newkrok/nape-js 3.31.0 → 3.33.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.
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkHQH77APJ_cjs=require('./chunk-HQH77APJ.cjs');var k=class{constructor(o=4096){this.pos=0;this.buf=new ArrayBuffer(o),this.view=new DataView(this.buf);}ensure(o){let r=this.pos+o;if(r<=this.buf.byteLength)return;let i=this.buf.byteLength;for(;i<r;)i*=2;let l=new ArrayBuffer(i);new Uint8Array(l).set(new Uint8Array(this.buf)),this.buf=l,this.view=new DataView(this.buf);}writeUint8(o){this.ensure(1),this.view.setUint8(this.pos,o),this.pos+=1;}writeUint16(o){this.ensure(2),this.view.setUint16(this.pos,o,true),this.pos+=2;}writeUint32(o){this.ensure(4),this.view.setUint32(this.pos,o,true),this.pos+=4;}writeInt32(o){this.ensure(4),this.view.setInt32(this.pos,o,true),this.pos+=4;}writeFloat64(o){this.ensure(8),this.view.setFloat64(this.pos,o,true),this.pos+=8;}writeBool(o){this.writeUint8(o?1:0);}finish(){return new Uint8Array(this.buf,0,this.pos)}};var rt=1312903237,N=2,it=0,at=1,st=2,lt=3,ct=4,dt=5,ut=6;function pt(t,o){t.writeFloat64(o.elasticity),t.writeFloat64(o.dynamicFriction),t.writeFloat64(o.staticFriction),t.writeFloat64(o.density),t.writeFloat64(o.rollingFriction);}function Ft(t,o){t.writeInt32(o.collisionGroup),t.writeInt32(o.collisionMask),t.writeInt32(o.sensorGroup),t.writeInt32(o.sensorMask),t.writeInt32(o.fluidGroup),t.writeInt32(o.fluidMask);}function mt(t,o){if(o==null)return;t.writeFloat64(o.density),t.writeFloat64(o.viscosity);let r=o.gravity;t.writeBool(r!=null),r!=null&&(t.writeFloat64(r.x),t.writeFloat64(r.y));}function ft(t,o){if(o.isCircle()){t.writeUint8(0);let e=o;t.writeFloat64(e.radius);let n=o.localCOM;t.writeFloat64(n.x),t.writeFloat64(n.y);}else if(o.isCapsule()){t.writeUint8(2);let e=o;t.writeFloat64(e.width),t.writeFloat64(e.height);let n=o.localCOM;t.writeFloat64(n.x),t.writeFloat64(n.y);}else {t.writeUint8(1);let n=o.localVerts,s=n.length;t.writeUint16(s);for(let c=0;c<s;c++){let u=n.at(c);t.writeFloat64(u.x),t.writeFloat64(u.y);}}pt(t,o.material),Ft(t,o.filter);let r=o.fluidEnabled,i=r&&o.fluidProperties!=null,l=(o.sensorEnabled?1:0)|(r?2:0)|(i?4:0);t.writeUint8(l),i&&mt(t,o.fluidProperties);}function yt(t,o){let r=o.zpp_inner;t.writeUint8(r.type),t.writeFloat64(o.position.x),t.writeFloat64(o.position.y),t.writeFloat64(o.rotation),t.writeFloat64(o.velocity.x),t.writeFloat64(o.velocity.y),t.writeFloat64(o.angularVel),t.writeFloat64(o.kinematicVel.x),t.writeFloat64(o.kinematicVel.y),t.writeFloat64(o.kinAngVel),t.writeFloat64(o.surfaceVel.x),t.writeFloat64(o.surfaceVel.y),t.writeFloat64(o.force.x),t.writeFloat64(o.force.y),t.writeFloat64(r.type===2?o.torque:0),t.writeUint8(r.massMode),t.writeFloat64(r.massMode===1?r.cmass:0),t.writeUint8(r.inertiaMode),t.writeFloat64(r.inertiaMode===1?r.cinertia:0),t.writeUint8(r.gravMassMode),t.writeFloat64(r.gravMassScale);let i=(o.allowMovement?1:0)|(o.allowRotation?2:0)|(o.isBullet?4:0);t.writeUint8(i);let l=o.shapes,e=l.length;t.writeUint16(e);for(let n=0;n<e;n++)ft(t,l.at(n));}var et={PivotJoint:it,DistanceJoint:at,AngleJoint:st,MotorJoint:lt,LineJoint:ct,PulleyJoint:dt,WeldJoint:ut};function A(t,o,r,i,l){let e=i!=null?r.get(i.zpp_inner.id)??-1:-1,n=l!=null?r.get(l.zpp_inner.id)??-1:-1;t.writeInt32(e),t.writeInt32(n);let s=o.zpp_inner,c=(s.active?1:0)|(s.ignore?2:0)|(s.stiff?4:0)|(s.breakUnderForce?8:0)|(s.breakUnderError?16:0)|(s.removeOnBreak?32:0);t.writeUint8(c),t.writeFloat64(s.frequency),t.writeFloat64(s.damping),t.writeFloat64(s.maxForce),t.writeFloat64(s.maxError);}function ht(t,o,r){let i=o.constructor?.name??"",l=et[i];if(l===void 0)return false;switch(t.writeUint8(l),i){case "PivotJoint":{let e=o;A(t,o,r,e.body1,e.body2),t.writeFloat64(e.anchor1.x),t.writeFloat64(e.anchor1.y),t.writeFloat64(e.anchor2.x),t.writeFloat64(e.anchor2.y);break}case "DistanceJoint":{let e=o;A(t,o,r,e.body1,e.body2),t.writeFloat64(e.anchor1.x),t.writeFloat64(e.anchor1.y),t.writeFloat64(e.anchor2.x),t.writeFloat64(e.anchor2.y),t.writeFloat64(e.jointMin),t.writeFloat64(e.jointMax);break}case "AngleJoint":{let e=o;A(t,o,r,e.body1,e.body2),t.writeFloat64(e.jointMin),t.writeFloat64(e.jointMax),t.writeFloat64(e.ratio);break}case "MotorJoint":{let e=o;A(t,o,r,e.body1,e.body2),t.writeFloat64(e.rate),t.writeFloat64(e.ratio);break}case "LineJoint":{let e=o;A(t,o,r,e.body1,e.body2),t.writeFloat64(e.anchor1.x),t.writeFloat64(e.anchor1.y),t.writeFloat64(e.anchor2.x),t.writeFloat64(e.anchor2.y),t.writeFloat64(e.direction.x),t.writeFloat64(e.direction.y),t.writeFloat64(e.jointMin),t.writeFloat64(e.jointMax);break}case "PulleyJoint":{let e=o;A(t,o,r,e.body1,e.body2),t.writeFloat64(e.anchor1.x),t.writeFloat64(e.anchor1.y),t.writeFloat64(e.anchor2.x),t.writeFloat64(e.anchor2.y),t.writeFloat64(e.anchor3.x),t.writeFloat64(e.anchor3.y),t.writeFloat64(e.anchor4.x),t.writeFloat64(e.anchor4.y),t.writeFloat64(e.jointMin),t.writeFloat64(e.jointMax),t.writeFloat64(e.ratio);break}case "WeldJoint":{let e=o;A(t,o,r,e.body1,e.body2),t.writeFloat64(e.anchor1.x),t.writeFloat64(e.anchor1.y),t.writeFloat64(e.anchor2.x),t.writeFloat64(e.anchor2.y),t.writeFloat64(e.phase);break}}return true}function Pt(t){let o=new k,r=[],i=new Map,l=new Map;function e(a){let m=a.zpp_inner.id;if(i.has(m))return;let h=r.length;l.set(a,h),i.set(m,h),r.push(a);}let n=t.bodies,s=n.length;for(let a=0;a<s;a++)e(n.at(a));let c=t.compounds,u=c.length;for(let a=0;a<u;a++){let h=c.at(a).bodies,b=h.length;for(let d=0;d<b;d++)e(h.at(d));}let F=[],f=new Map;function w(a){if(f.has(a))return;let m=a.constructor?.name??"";et[m]!==void 0&&(f.set(a,F.length),F.push(a));}let U=t.constraints,C=U.length;for(let a=0;a<C;a++)w(U.at(a));for(let a=0;a<u;a++){let h=c.at(a).constraints,b=h.length;for(let d=0;d<b;d++)w(h.at(d));}o.writeUint32(rt),o.writeUint16(N),o.writeUint32(r.length),o.writeUint32(F.length),o.writeUint32(u);let y=t.gravity;o.writeFloat64(y.x),o.writeFloat64(y.y),o.writeFloat64(t.worldLinearDrag),o.writeFloat64(t.worldAngularDrag),o.writeBool(t.sortContacts),o.writeBool(t.deterministic),o.writeUint8(t.zpp_inner.bphase.is_sweep?0:1);for(let a=0;a<r.length;a++)yt(o,r[a]);for(let a=0;a<F.length;a++)ht(o,F[a],i);for(let a=0;a<u;a++){let m=c.at(a),h=m.bodies,b=h.length;o.writeUint16(b);for(let g=0;g<b;g++){let I=h.at(g),v=l.get(I)??0;o.writeUint32(v);}let d=m.constraints,M=d.length,T=0;for(let g=0;g<M;g++){let I=d.at(g);f.has(I)&&T++;}o.writeUint16(T);for(let g=0;g<M;g++){let I=d.at(g),v=f.get(I);v!=null&&o.writeUint32(v);}o.writeUint16(0);}return o.finish()}var P=class{constructor(o){this.pos=0;this.view=new DataView(o.buffer,o.byteOffset,o.byteLength);}readUint8(){let o=this.view.getUint8(this.pos);return this.pos+=1,o}readUint16(){let o=this.view.getUint16(this.pos,true);return this.pos+=2,o}readUint32(){let o=this.view.getUint32(this.pos,true);return this.pos+=4,o}readInt32(){let o=this.view.getInt32(this.pos,true);return this.pos+=4,o}readFloat64(){let o=this.view.getFloat64(this.pos,true);return this.pos+=8,o}readBool(){return this.readUint8()!==0}};var nt=1312903237,wt=0,bt=1,gt=2,vt=3,Ct=4,Ut=5,Mt=6,It={1:chunkHQH77APJ_cjs.aa.STATIC,2:chunkHQH77APJ_cjs.aa.DYNAMIC,3:chunkHQH77APJ_cjs.aa.KINEMATIC};function O(t){let o=t.readFloat64(),r=t.readFloat64(),i=t.readFloat64(),l=t.readFloat64(),e=t.readFloat64();return new chunkHQH77APJ_cjs.ca(o,r,i,l,e)}function R(t){let o=new chunkHQH77APJ_cjs.ha;return o.collisionGroup=t.readInt32(),o.collisionMask=t.readInt32(),o.sensorGroup=t.readInt32(),o.sensorMask=t.readInt32(),o.fluidGroup=t.readInt32(),o.fluidMask=t.readInt32(),o}function At(t){let o=t.readFloat64(),r=t.readFloat64(),i=new chunkHQH77APJ_cjs.U(o,r);return t.readBool()&&(i.gravity=chunkHQH77APJ_cjs.I.get(t.readFloat64(),t.readFloat64())),i}function xt(t){let o=t.readUint8(),r;if(o===0){let e=t.readFloat64(),n=t.readFloat64(),s=t.readFloat64(),c=O(t),u=R(t);r=new chunkHQH77APJ_cjs.ga(e,chunkHQH77APJ_cjs.I.weak(n,s),c,u);}else if(o===2){let e=t.readFloat64(),n=t.readFloat64(),s=t.readFloat64(),c=t.readFloat64(),u=O(t),F=R(t);r=new chunkHQH77APJ_cjs.ja(e,n,chunkHQH77APJ_cjs.I.weak(s,c),u,F);}else {let e=t.readUint16(),n=[];for(let u=0;u<e;u++)n.push(chunkHQH77APJ_cjs.I.get(t.readFloat64(),t.readFloat64()));let s=O(t),c=R(t);r=new chunkHQH77APJ_cjs.ia(n,s,c);}let i=t.readUint8();return r.sensorEnabled=(i&1)!==0,r.fluidEnabled=(i&2)!==0,(i&4)!==0&&(r.fluidProperties=At(t)),r}function Bt(t){let o=t.readUint8(),r=It[o]??chunkHQH77APJ_cjs.aa.DYNAMIC,i=t.readFloat64(),l=t.readFloat64(),e=t.readFloat64(),n=new chunkHQH77APJ_cjs.$(r,chunkHQH77APJ_cjs.I.weak(i,l));n.rotation=e;let s=t.readFloat64(),c=t.readFloat64(),u=t.readFloat64();o!==1&&(n.velocity=chunkHQH77APJ_cjs.I.get(s,c),n.angularVel=u),n.kinematicVel=chunkHQH77APJ_cjs.I.get(t.readFloat64(),t.readFloat64()),n.kinAngVel=t.readFloat64(),n.surfaceVel=chunkHQH77APJ_cjs.I.get(t.readFloat64(),t.readFloat64());let F=t.readFloat64(),f=t.readFloat64(),w=t.readFloat64();o===2&&(n.force=chunkHQH77APJ_cjs.I.get(F,f),n.torque=w);let U=t.readUint8(),C=t.readFloat64();U===1&&C!==0?n.mass=C:U===0&&(n.massMode=chunkHQH77APJ_cjs.fa.DEFAULT);let y=t.readUint8(),a=t.readFloat64();y===1&&a!==0?n.inertia=a:y===0&&(n.inertiaMode=chunkHQH77APJ_cjs.ea.DEFAULT);let m=t.readUint8(),h=t.readFloat64();m===2?(n.gravMassMode=chunkHQH77APJ_cjs.da.SCALED,n.gravMassScale=h):m===1&&(n.gravMassMode=chunkHQH77APJ_cjs.da.FIXED);let b=t.readUint8();n.allowMovement=(b&1)!==0,n.allowRotation=(b&2)!==0,n.isBullet=(b&4)!==0;let d=t.readUint16();for(let M=0;M<d;M++)xt(t).body=n;return n}function Jt(t){let o=t.readInt32(),r=t.readInt32(),i=t.readUint8(),l=t.readFloat64(),e=t.readFloat64(),n=t.readFloat64(),s=t.readFloat64();return {body1Id:o,body2Id:r,active:(i&1)!==0,ignore:(i&2)!==0,stiff:(i&4)!==0,breakUnderForce:(i&8)!==0,breakUnderError:(i&16)!==0,removeOnBreak:(i&32)!==0,frequency:l,damping:e,maxForce:n,maxError:s}}function x(t,o){t.active=o.active,t.ignore=o.ignore,t.stiff=o.stiff,t.frequency=o.frequency,t.damping=o.damping,t.maxForce=o.maxForce,t.maxError=o.maxError,t.breakUnderForce=o.breakUnderForce,t.breakUnderError=o.breakUnderError,t.removeOnBreak=o.removeOnBreak;}function Tt(t,o){let r=t.readUint8(),i=Jt(t),l=i.body1Id>=0?o[i.body1Id]??null:null,e=i.body2Id>=0?o[i.body2Id]??null:null;switch(r){case wt:{let n=t.readFloat64(),s=t.readFloat64(),c=t.readFloat64(),u=t.readFloat64(),F=new chunkHQH77APJ_cjs.qa(l,e,chunkHQH77APJ_cjs.I.weak(n,s),chunkHQH77APJ_cjs.I.weak(c,u));return x(F,i),F}case bt:{let n=t.readFloat64(),s=t.readFloat64(),c=t.readFloat64(),u=t.readFloat64(),F=t.readFloat64(),f=t.readFloat64(),w=new chunkHQH77APJ_cjs.na(l,e,chunkHQH77APJ_cjs.I.weak(n,s),chunkHQH77APJ_cjs.I.weak(c,u),F,f);return x(w,i),w}case gt:{let n=t.readFloat64(),s=t.readFloat64(),c=t.readFloat64(),u=new chunkHQH77APJ_cjs.ma(l,e,n,s,c);return x(u,i),u}case vt:{let n=t.readFloat64(),s=t.readFloat64(),c=new chunkHQH77APJ_cjs.pa(l,e,n,s);return x(c,i),c}case Ct:{let n=t.readFloat64(),s=t.readFloat64(),c=t.readFloat64(),u=t.readFloat64(),F=t.readFloat64(),f=t.readFloat64(),w=t.readFloat64(),U=t.readFloat64(),C=new chunkHQH77APJ_cjs.oa(l,e,chunkHQH77APJ_cjs.I.weak(n,s),chunkHQH77APJ_cjs.I.weak(c,u),chunkHQH77APJ_cjs.I.weak(F,f),w,U);return x(C,i),C}case Ut:{let n=t.readFloat64(),s=t.readFloat64(),c=t.readFloat64(),u=t.readFloat64(),F=t.readFloat64(),f=t.readFloat64(),w=t.readFloat64(),U=t.readFloat64(),C=t.readFloat64(),y=t.readFloat64(),a=t.readFloat64(),m=new chunkHQH77APJ_cjs.ra(l,e,null,null,chunkHQH77APJ_cjs.I.weak(n,s),chunkHQH77APJ_cjs.I.weak(c,u),chunkHQH77APJ_cjs.I.weak(F,f),chunkHQH77APJ_cjs.I.weak(w,U),C,y,a);return x(m,i),m}case Mt:{let n=t.readFloat64(),s=t.readFloat64(),c=t.readFloat64(),u=t.readFloat64(),F=t.readFloat64(),f=new chunkHQH77APJ_cjs.sa(l,e,chunkHQH77APJ_cjs.I.weak(n,s),chunkHQH77APJ_cjs.I.weak(c,u),F);return x(f,i),f}default:throw new Error(`nape-js binary: unknown constraint type tag ${r}`)}}function ao(t){let o=new P(t),r=o.readUint32();if(r!==nt)throw new Error(`nape-js binary: invalid magic bytes 0x${r.toString(16)} (expected 0x${nt.toString(16)})`);let i=o.readUint16();if(i!==N)throw new Error(`nape-js binary: unsupported version ${i} (expected ${N})`);let l=o.readUint32(),e=o.readUint32(),n=o.readUint32(),s=o.readFloat64(),c=o.readFloat64(),u=o.readFloat64(),F=o.readFloat64(),f=o.readBool(),w=o.readBool(),C=o.readUint8()===0?chunkHQH77APJ_cjs.ka.SWEEP_AND_PRUNE:chunkHQH77APJ_cjs.ka.DYNAMIC_AABB_TREE,y=new chunkHQH77APJ_cjs.Y(chunkHQH77APJ_cjs.I.weak(s,c),C);y.worldLinearDrag=u,y.worldAngularDrag=F,y.sortContacts=f,y.deterministic=w;let a=new Array(l);for(let d=0;d<l;d++)a[d]=Bt(o);let m=new Array(e);for(let d=0;d<e;d++)m[d]=Tt(o,a);let h=new Set,b=new Set;for(let d=0;d<n;d++){let M=new chunkHQH77APJ_cjs.ba,T=o.readUint16();for(let v=0;v<T;v++){let B=o.readUint32();a[B].compound=M,h.add(B);}let g=o.readUint16();for(let v=0;v<g;v++){let B=o.readUint32();m[B].compound=M,b.add(B);}let I=o.readUint16();for(let v=0;v<I;v++)o.readUint32();M.space=y;}for(let d=0;d<l;d++)h.has(d)||(a[d].space=y);for(let d=0;d<e;d++)b.has(d)||(m[d].space=y);return y}exports.a=N;exports.b=Pt;exports.c=ao;//# sourceMappingURL=chunk-CA2F5ISB.cjs.map
2
+ //# sourceMappingURL=chunk-CA2F5ISB.cjs.map
@@ -0,0 +1,2 @@
1
+ import {aa,ka,Y,I,ba,$,fa,ea,da,sa,ra,oa,pa,ma,na,qa,ga,ja,ia,ca,ha,U}from'./chunk-263GQ5UK.js';var k=class{constructor(o=4096){this.pos=0;this.buf=new ArrayBuffer(o),this.view=new DataView(this.buf);}ensure(o){let r=this.pos+o;if(r<=this.buf.byteLength)return;let i=this.buf.byteLength;for(;i<r;)i*=2;let l=new ArrayBuffer(i);new Uint8Array(l).set(new Uint8Array(this.buf)),this.buf=l,this.view=new DataView(this.buf);}writeUint8(o){this.ensure(1),this.view.setUint8(this.pos,o),this.pos+=1;}writeUint16(o){this.ensure(2),this.view.setUint16(this.pos,o,true),this.pos+=2;}writeUint32(o){this.ensure(4),this.view.setUint32(this.pos,o,true),this.pos+=4;}writeInt32(o){this.ensure(4),this.view.setInt32(this.pos,o,true),this.pos+=4;}writeFloat64(o){this.ensure(8),this.view.setFloat64(this.pos,o,true),this.pos+=8;}writeBool(o){this.writeUint8(o?1:0);}finish(){return new Uint8Array(this.buf,0,this.pos)}};var rt=1312903237,N=2,it=0,at=1,st=2,lt=3,ct=4,dt=5,ut=6;function pt(t,o){t.writeFloat64(o.elasticity),t.writeFloat64(o.dynamicFriction),t.writeFloat64(o.staticFriction),t.writeFloat64(o.density),t.writeFloat64(o.rollingFriction);}function Ft(t,o){t.writeInt32(o.collisionGroup),t.writeInt32(o.collisionMask),t.writeInt32(o.sensorGroup),t.writeInt32(o.sensorMask),t.writeInt32(o.fluidGroup),t.writeInt32(o.fluidMask);}function mt(t,o){if(o==null)return;t.writeFloat64(o.density),t.writeFloat64(o.viscosity);let r=o.gravity;t.writeBool(r!=null),r!=null&&(t.writeFloat64(r.x),t.writeFloat64(r.y));}function ft(t,o){if(o.isCircle()){t.writeUint8(0);let e=o;t.writeFloat64(e.radius);let n=o.localCOM;t.writeFloat64(n.x),t.writeFloat64(n.y);}else if(o.isCapsule()){t.writeUint8(2);let e=o;t.writeFloat64(e.width),t.writeFloat64(e.height);let n=o.localCOM;t.writeFloat64(n.x),t.writeFloat64(n.y);}else {t.writeUint8(1);let n=o.localVerts,s=n.length;t.writeUint16(s);for(let c=0;c<s;c++){let u=n.at(c);t.writeFloat64(u.x),t.writeFloat64(u.y);}}pt(t,o.material),Ft(t,o.filter);let r=o.fluidEnabled,i=r&&o.fluidProperties!=null,l=(o.sensorEnabled?1:0)|(r?2:0)|(i?4:0);t.writeUint8(l),i&&mt(t,o.fluidProperties);}function yt(t,o){let r=o.zpp_inner;t.writeUint8(r.type),t.writeFloat64(o.position.x),t.writeFloat64(o.position.y),t.writeFloat64(o.rotation),t.writeFloat64(o.velocity.x),t.writeFloat64(o.velocity.y),t.writeFloat64(o.angularVel),t.writeFloat64(o.kinematicVel.x),t.writeFloat64(o.kinematicVel.y),t.writeFloat64(o.kinAngVel),t.writeFloat64(o.surfaceVel.x),t.writeFloat64(o.surfaceVel.y),t.writeFloat64(o.force.x),t.writeFloat64(o.force.y),t.writeFloat64(r.type===2?o.torque:0),t.writeUint8(r.massMode),t.writeFloat64(r.massMode===1?r.cmass:0),t.writeUint8(r.inertiaMode),t.writeFloat64(r.inertiaMode===1?r.cinertia:0),t.writeUint8(r.gravMassMode),t.writeFloat64(r.gravMassScale);let i=(o.allowMovement?1:0)|(o.allowRotation?2:0)|(o.isBullet?4:0);t.writeUint8(i);let l=o.shapes,e=l.length;t.writeUint16(e);for(let n=0;n<e;n++)ft(t,l.at(n));}var et={PivotJoint:it,DistanceJoint:at,AngleJoint:st,MotorJoint:lt,LineJoint:ct,PulleyJoint:dt,WeldJoint:ut};function A(t,o,r,i,l){let e=i!=null?r.get(i.zpp_inner.id)??-1:-1,n=l!=null?r.get(l.zpp_inner.id)??-1:-1;t.writeInt32(e),t.writeInt32(n);let s=o.zpp_inner,c=(s.active?1:0)|(s.ignore?2:0)|(s.stiff?4:0)|(s.breakUnderForce?8:0)|(s.breakUnderError?16:0)|(s.removeOnBreak?32:0);t.writeUint8(c),t.writeFloat64(s.frequency),t.writeFloat64(s.damping),t.writeFloat64(s.maxForce),t.writeFloat64(s.maxError);}function ht(t,o,r){let i=o.constructor?.name??"",l=et[i];if(l===void 0)return false;switch(t.writeUint8(l),i){case "PivotJoint":{let e=o;A(t,o,r,e.body1,e.body2),t.writeFloat64(e.anchor1.x),t.writeFloat64(e.anchor1.y),t.writeFloat64(e.anchor2.x),t.writeFloat64(e.anchor2.y);break}case "DistanceJoint":{let e=o;A(t,o,r,e.body1,e.body2),t.writeFloat64(e.anchor1.x),t.writeFloat64(e.anchor1.y),t.writeFloat64(e.anchor2.x),t.writeFloat64(e.anchor2.y),t.writeFloat64(e.jointMin),t.writeFloat64(e.jointMax);break}case "AngleJoint":{let e=o;A(t,o,r,e.body1,e.body2),t.writeFloat64(e.jointMin),t.writeFloat64(e.jointMax),t.writeFloat64(e.ratio);break}case "MotorJoint":{let e=o;A(t,o,r,e.body1,e.body2),t.writeFloat64(e.rate),t.writeFloat64(e.ratio);break}case "LineJoint":{let e=o;A(t,o,r,e.body1,e.body2),t.writeFloat64(e.anchor1.x),t.writeFloat64(e.anchor1.y),t.writeFloat64(e.anchor2.x),t.writeFloat64(e.anchor2.y),t.writeFloat64(e.direction.x),t.writeFloat64(e.direction.y),t.writeFloat64(e.jointMin),t.writeFloat64(e.jointMax);break}case "PulleyJoint":{let e=o;A(t,o,r,e.body1,e.body2),t.writeFloat64(e.anchor1.x),t.writeFloat64(e.anchor1.y),t.writeFloat64(e.anchor2.x),t.writeFloat64(e.anchor2.y),t.writeFloat64(e.anchor3.x),t.writeFloat64(e.anchor3.y),t.writeFloat64(e.anchor4.x),t.writeFloat64(e.anchor4.y),t.writeFloat64(e.jointMin),t.writeFloat64(e.jointMax),t.writeFloat64(e.ratio);break}case "WeldJoint":{let e=o;A(t,o,r,e.body1,e.body2),t.writeFloat64(e.anchor1.x),t.writeFloat64(e.anchor1.y),t.writeFloat64(e.anchor2.x),t.writeFloat64(e.anchor2.y),t.writeFloat64(e.phase);break}}return true}function Pt(t){let o=new k,r=[],i=new Map,l=new Map;function e(a){let m=a.zpp_inner.id;if(i.has(m))return;let h=r.length;l.set(a,h),i.set(m,h),r.push(a);}let n=t.bodies,s=n.length;for(let a=0;a<s;a++)e(n.at(a));let c=t.compounds,u=c.length;for(let a=0;a<u;a++){let h=c.at(a).bodies,b=h.length;for(let d=0;d<b;d++)e(h.at(d));}let F=[],f=new Map;function w(a){if(f.has(a))return;let m=a.constructor?.name??"";et[m]!==void 0&&(f.set(a,F.length),F.push(a));}let U=t.constraints,C=U.length;for(let a=0;a<C;a++)w(U.at(a));for(let a=0;a<u;a++){let h=c.at(a).constraints,b=h.length;for(let d=0;d<b;d++)w(h.at(d));}o.writeUint32(rt),o.writeUint16(N),o.writeUint32(r.length),o.writeUint32(F.length),o.writeUint32(u);let y=t.gravity;o.writeFloat64(y.x),o.writeFloat64(y.y),o.writeFloat64(t.worldLinearDrag),o.writeFloat64(t.worldAngularDrag),o.writeBool(t.sortContacts),o.writeBool(t.deterministic),o.writeUint8(t.zpp_inner.bphase.is_sweep?0:1);for(let a=0;a<r.length;a++)yt(o,r[a]);for(let a=0;a<F.length;a++)ht(o,F[a],i);for(let a=0;a<u;a++){let m=c.at(a),h=m.bodies,b=h.length;o.writeUint16(b);for(let g=0;g<b;g++){let I=h.at(g),v=l.get(I)??0;o.writeUint32(v);}let d=m.constraints,M=d.length,T=0;for(let g=0;g<M;g++){let I=d.at(g);f.has(I)&&T++;}o.writeUint16(T);for(let g=0;g<M;g++){let I=d.at(g),v=f.get(I);v!=null&&o.writeUint32(v);}o.writeUint16(0);}return o.finish()}var P=class{constructor(o){this.pos=0;this.view=new DataView(o.buffer,o.byteOffset,o.byteLength);}readUint8(){let o=this.view.getUint8(this.pos);return this.pos+=1,o}readUint16(){let o=this.view.getUint16(this.pos,true);return this.pos+=2,o}readUint32(){let o=this.view.getUint32(this.pos,true);return this.pos+=4,o}readInt32(){let o=this.view.getInt32(this.pos,true);return this.pos+=4,o}readFloat64(){let o=this.view.getFloat64(this.pos,true);return this.pos+=8,o}readBool(){return this.readUint8()!==0}};var nt=1312903237,wt=0,bt=1,gt=2,vt=3,Ct=4,Ut=5,Mt=6,It={1:aa.STATIC,2:aa.DYNAMIC,3:aa.KINEMATIC};function O(t){let o=t.readFloat64(),r=t.readFloat64(),i=t.readFloat64(),l=t.readFloat64(),e=t.readFloat64();return new ca(o,r,i,l,e)}function R(t){let o=new ha;return o.collisionGroup=t.readInt32(),o.collisionMask=t.readInt32(),o.sensorGroup=t.readInt32(),o.sensorMask=t.readInt32(),o.fluidGroup=t.readInt32(),o.fluidMask=t.readInt32(),o}function At(t){let o=t.readFloat64(),r=t.readFloat64(),i=new U(o,r);return t.readBool()&&(i.gravity=I.get(t.readFloat64(),t.readFloat64())),i}function xt(t){let o=t.readUint8(),r;if(o===0){let e=t.readFloat64(),n=t.readFloat64(),s=t.readFloat64(),c=O(t),u=R(t);r=new ga(e,I.weak(n,s),c,u);}else if(o===2){let e=t.readFloat64(),n=t.readFloat64(),s=t.readFloat64(),c=t.readFloat64(),u=O(t),F=R(t);r=new ja(e,n,I.weak(s,c),u,F);}else {let e=t.readUint16(),n=[];for(let u=0;u<e;u++)n.push(I.get(t.readFloat64(),t.readFloat64()));let s=O(t),c=R(t);r=new ia(n,s,c);}let i=t.readUint8();return r.sensorEnabled=(i&1)!==0,r.fluidEnabled=(i&2)!==0,(i&4)!==0&&(r.fluidProperties=At(t)),r}function Bt(t){let o=t.readUint8(),r=It[o]??aa.DYNAMIC,i=t.readFloat64(),l=t.readFloat64(),e=t.readFloat64(),n=new $(r,I.weak(i,l));n.rotation=e;let s=t.readFloat64(),c=t.readFloat64(),u=t.readFloat64();o!==1&&(n.velocity=I.get(s,c),n.angularVel=u),n.kinematicVel=I.get(t.readFloat64(),t.readFloat64()),n.kinAngVel=t.readFloat64(),n.surfaceVel=I.get(t.readFloat64(),t.readFloat64());let F=t.readFloat64(),f=t.readFloat64(),w=t.readFloat64();o===2&&(n.force=I.get(F,f),n.torque=w);let U=t.readUint8(),C=t.readFloat64();U===1&&C!==0?n.mass=C:U===0&&(n.massMode=fa.DEFAULT);let y=t.readUint8(),a=t.readFloat64();y===1&&a!==0?n.inertia=a:y===0&&(n.inertiaMode=ea.DEFAULT);let m=t.readUint8(),h=t.readFloat64();m===2?(n.gravMassMode=da.SCALED,n.gravMassScale=h):m===1&&(n.gravMassMode=da.FIXED);let b=t.readUint8();n.allowMovement=(b&1)!==0,n.allowRotation=(b&2)!==0,n.isBullet=(b&4)!==0;let d=t.readUint16();for(let M=0;M<d;M++)xt(t).body=n;return n}function Jt(t){let o=t.readInt32(),r=t.readInt32(),i=t.readUint8(),l=t.readFloat64(),e=t.readFloat64(),n=t.readFloat64(),s=t.readFloat64();return {body1Id:o,body2Id:r,active:(i&1)!==0,ignore:(i&2)!==0,stiff:(i&4)!==0,breakUnderForce:(i&8)!==0,breakUnderError:(i&16)!==0,removeOnBreak:(i&32)!==0,frequency:l,damping:e,maxForce:n,maxError:s}}function x(t,o){t.active=o.active,t.ignore=o.ignore,t.stiff=o.stiff,t.frequency=o.frequency,t.damping=o.damping,t.maxForce=o.maxForce,t.maxError=o.maxError,t.breakUnderForce=o.breakUnderForce,t.breakUnderError=o.breakUnderError,t.removeOnBreak=o.removeOnBreak;}function Tt(t,o){let r=t.readUint8(),i=Jt(t),l=i.body1Id>=0?o[i.body1Id]??null:null,e=i.body2Id>=0?o[i.body2Id]??null:null;switch(r){case wt:{let n=t.readFloat64(),s=t.readFloat64(),c=t.readFloat64(),u=t.readFloat64(),F=new qa(l,e,I.weak(n,s),I.weak(c,u));return x(F,i),F}case bt:{let n=t.readFloat64(),s=t.readFloat64(),c=t.readFloat64(),u=t.readFloat64(),F=t.readFloat64(),f=t.readFloat64(),w=new na(l,e,I.weak(n,s),I.weak(c,u),F,f);return x(w,i),w}case gt:{let n=t.readFloat64(),s=t.readFloat64(),c=t.readFloat64(),u=new ma(l,e,n,s,c);return x(u,i),u}case vt:{let n=t.readFloat64(),s=t.readFloat64(),c=new pa(l,e,n,s);return x(c,i),c}case Ct:{let n=t.readFloat64(),s=t.readFloat64(),c=t.readFloat64(),u=t.readFloat64(),F=t.readFloat64(),f=t.readFloat64(),w=t.readFloat64(),U=t.readFloat64(),C=new oa(l,e,I.weak(n,s),I.weak(c,u),I.weak(F,f),w,U);return x(C,i),C}case Ut:{let n=t.readFloat64(),s=t.readFloat64(),c=t.readFloat64(),u=t.readFloat64(),F=t.readFloat64(),f=t.readFloat64(),w=t.readFloat64(),U=t.readFloat64(),C=t.readFloat64(),y=t.readFloat64(),a=t.readFloat64(),m=new ra(l,e,null,null,I.weak(n,s),I.weak(c,u),I.weak(F,f),I.weak(w,U),C,y,a);return x(m,i),m}case Mt:{let n=t.readFloat64(),s=t.readFloat64(),c=t.readFloat64(),u=t.readFloat64(),F=t.readFloat64(),f=new sa(l,e,I.weak(n,s),I.weak(c,u),F);return x(f,i),f}default:throw new Error(`nape-js binary: unknown constraint type tag ${r}`)}}function ao(t){let o=new P(t),r=o.readUint32();if(r!==nt)throw new Error(`nape-js binary: invalid magic bytes 0x${r.toString(16)} (expected 0x${nt.toString(16)})`);let i=o.readUint16();if(i!==N)throw new Error(`nape-js binary: unsupported version ${i} (expected ${N})`);let l=o.readUint32(),e=o.readUint32(),n=o.readUint32(),s=o.readFloat64(),c=o.readFloat64(),u=o.readFloat64(),F=o.readFloat64(),f=o.readBool(),w=o.readBool(),C=o.readUint8()===0?ka.SWEEP_AND_PRUNE:ka.DYNAMIC_AABB_TREE,y=new Y(I.weak(s,c),C);y.worldLinearDrag=u,y.worldAngularDrag=F,y.sortContacts=f,y.deterministic=w;let a=new Array(l);for(let d=0;d<l;d++)a[d]=Bt(o);let m=new Array(e);for(let d=0;d<e;d++)m[d]=Tt(o,a);let h=new Set,b=new Set;for(let d=0;d<n;d++){let M=new ba,T=o.readUint16();for(let v=0;v<T;v++){let B=o.readUint32();a[B].compound=M,h.add(B);}let g=o.readUint16();for(let v=0;v<g;v++){let B=o.readUint32();m[B].compound=M,b.add(B);}let I=o.readUint16();for(let v=0;v<I;v++)o.readUint32();M.space=y;}for(let d=0;d<l;d++)h.has(d)||(a[d].space=y);for(let d=0;d<e;d++)b.has(d)||(m[d].space=y);return y}export{N as a,Pt as b,ao as c};//# sourceMappingURL=chunk-GPGT7DYQ.js.map
2
+ //# sourceMappingURL=chunk-GPGT7DYQ.js.map