@newkrok/nape-js 3.38.0 → 3.38.1

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.
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkCA2F5ISB_cjs=require('../chunk-CA2F5ISB.cjs');require('../chunk-HQH77APJ.cjs');var _=class{constructor(t,e={}){this._inputs=[];this._keyframes=[];this._frame=0;this._finished=false;if(t==null)throw new Error("Recorder: space is required");let i=e.keyframeEvery;if(i!=null&&(!Number.isFinite(i)||i<0||(i|0)!==i))throw new Error(`Recorder: keyframeEvery must be a non-negative integer (got ${i})`);this._space=t,this._keyframeEvery=i??60,this._initialSnapshot=chunkCA2F5ISB_cjs.b(t);}get frame(){return this._frame}get finished(){return this._finished}recordFrame(t){if(this._finished)throw new Error("Recorder: cannot record after finish()");if(this._keyframeEvery>0&&this._frame>0&&this._frame%this._keyframeEvery===0&&this._keyframes.push({frame:this._frame,snapshot:chunkCA2F5ISB_cjs.b(this._space)}),t!=null){let e=v(t);this._inputs.push({frame:this._frame,payload:e});}this._frame++;}finish(){return this._finished=true,{version:f,initialSnapshot:this._initialSnapshot,inputs:this._inputs.slice(),keyframes:this._keyframes.slice(),frameCount:this._frame}}},f=1;function v(r){let t=typeof r;return r===null||t==="number"||t==="string"||t==="boolean"?r:JSON.parse(JSON.stringify(r))}var d=class{constructor(t,e=null,i={}){this._space=null;this._frame=0;if(t==null)throw new Error("Player: replay is required");this._replay=t,this._applyInput=e,this._dt=i.dt??1/60,this._velocityIterations=i.velocityIterations??8,this._positionIterations=i.positionIterations??3;}restore(){return this._space=chunkCA2F5ISB_cjs.c(this._replay.initialSnapshot),this._frame=0,this._space}get space(){if(this._space==null)throw new Error("Player: call restore() before reading space");return this._space}get frame(){return this._frame}get frameCount(){return this._replay.frameCount}get finished(){return this._frame>=this._replay.frameCount}get replay(){return this._replay}get applyInput(){return this._applyInput}set applyInput(t){this._applyInput=t;}step(){if(this._space==null)throw new Error("Player: call restore() before step()");if(this._frame>=this._replay.frameCount)throw new Error(`Player: already at end of replay (frame ${this._frame}/${this._replay.frameCount})`);let t=I(this._replay.inputs,this._frame);t!=null&&this._applyInput!=null&&this._applyInput(t.payload,this._space,this._frame),this._space.step(this._dt,this._velocityIterations,this._positionIterations),this._frame++;}stepTo(t){if(!Number.isFinite(t)||t<0||t>this._replay.frameCount)throw new Error(`Player: target frame ${t} out of range [0, ${this._replay.frameCount}]`);if(this._space==null&&this.restore(),t<this._frame){let e=S(this._replay.keyframes,t);e!=null?(this._space=chunkCA2F5ISB_cjs.c(e.snapshot),this._frame=e.frame):this.restore();}for(;this._frame<t;)this.step();}};function I(r,t){let e=0,i=r.length-1;for(;e<=i;){let a=e+i>>>1,o=r[a].frame;if(o===t)return r[a];o<t?e=a+1:i=a-1;}return null}function S(r,t){let e=0,i=r.length-1,a=null;for(;e<=i;){let o=e+i>>>1,n=r[o];n.frame<=t?(a=n,e=o+1):i=o-1;}return a}var R=1380994137,T=new TextEncoder,E=new TextDecoder;function U(r){let t=[];for(let s of r.inputs){let u=JSON.stringify(s.payload);t.push({frame:s.frame,bytes:T.encode(u??"null")});}let e=14+r.initialSnapshot.byteLength;e+=4;for(let s of t)e+=8+s.bytes.byteLength;e+=4;for(let s of r.keyframes)e+=8+s.snapshot.byteLength;let i=new ArrayBuffer(e),a=new DataView(i),o=new Uint8Array(i),n=0;a.setUint32(n,R,false),n+=4,a.setUint16(n,r.version,true),n+=2,a.setUint32(n,r.frameCount,true),n+=4,a.setUint32(n,r.initialSnapshot.byteLength,true),n+=4,o.set(r.initialSnapshot,n),n+=r.initialSnapshot.byteLength,a.setUint32(n,t.length,true),n+=4;for(let s of t)a.setUint32(n,s.frame,true),n+=4,a.setUint32(n,s.bytes.byteLength,true),n+=4,o.set(s.bytes,n),n+=s.bytes.byteLength;a.setUint32(n,r.keyframes.length,true),n+=4;for(let s of r.keyframes)a.setUint32(n,s.frame,true),n+=4,a.setUint32(n,s.snapshot.byteLength,true),n+=4,o.set(s.snapshot,n),n+=s.snapshot.byteLength;return o}function k(r){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),e=0,i=t.getUint32(e,false);if(e+=4,i!==R)throw new Error(`decodeReplay: invalid magic 0x${i.toString(16).padStart(8,"0")} (expected 0x${R.toString(16)})`);let a=t.getUint16(e,true);if(e+=2,a!==f)throw new Error(`decodeReplay: unsupported version ${a} (expected ${f})`);let o=t.getUint32(e,true);e+=4;let n=t.getUint32(e,true);e+=4;let s=r.slice(e,e+n);e+=n;let u=t.getUint32(e,true);e+=4;let b=new Array(u);for(let p=0;p<u;p++){let m=t.getUint32(e,true);e+=4;let l=t.getUint32(e,true);e+=4;let y=E.decode(r.subarray(e,e+l));e+=l,b[p]={frame:m,payload:JSON.parse(y)};}let g=t.getUint32(e,true);e+=4;let w=new Array(g);for(let p=0;p<g;p++){let m=t.getUint32(e,true);e+=4;let l=t.getUint32(e,true);e+=4;let y=r.slice(e,e+l);e+=l,w[p]={frame:m,snapshot:y};}return {version:a,initialSnapshot:s,inputs:b,keyframes:w,frameCount:o}}function A(r){let t=[];return r==null?{ok:false,warnings:["space is null"]}:(r.deterministic||t.push("space.deterministic is false \u2014 replays will drift from the recording. Set space.deterministic = true."),{ok:t.length===0,warnings:t})}exports.Player=d;exports.REPLAY_VERSION=f;exports.Recorder=_;exports.decodeReplay=k;exports.encodeReplay=U;exports.validateDeterministicConfig=A;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var chunkQ2WPJQGU_cjs=require('../chunk-Q2WPJQGU.cjs');require('../chunk-WB53BIOZ.cjs');var _=class{constructor(t,e={}){this._inputs=[];this._keyframes=[];this._frame=0;this._finished=false;if(t==null)throw new Error("Recorder: space is required");let i=e.keyframeEvery;if(i!=null&&(!Number.isFinite(i)||i<0||(i|0)!==i))throw new Error(`Recorder: keyframeEvery must be a non-negative integer (got ${i})`);this._space=t,this._keyframeEvery=i??60,this._initialSnapshot=chunkQ2WPJQGU_cjs.b(t);}get frame(){return this._frame}get finished(){return this._finished}recordFrame(t){if(this._finished)throw new Error("Recorder: cannot record after finish()");if(this._keyframeEvery>0&&this._frame>0&&this._frame%this._keyframeEvery===0&&this._keyframes.push({frame:this._frame,snapshot:chunkQ2WPJQGU_cjs.b(this._space)}),t!=null){let e=v(t);this._inputs.push({frame:this._frame,payload:e});}this._frame++;}finish(){return this._finished=true,{version:f,initialSnapshot:this._initialSnapshot,inputs:this._inputs.slice(),keyframes:this._keyframes.slice(),frameCount:this._frame}}},f=1;function v(r){let t=typeof r;return r===null||t==="number"||t==="string"||t==="boolean"?r:JSON.parse(JSON.stringify(r))}var d=class{constructor(t,e=null,i={}){this._space=null;this._frame=0;if(t==null)throw new Error("Player: replay is required");this._replay=t,this._applyInput=e,this._dt=i.dt??1/60,this._velocityIterations=i.velocityIterations??8,this._positionIterations=i.positionIterations??3;}restore(){return this._space=chunkQ2WPJQGU_cjs.c(this._replay.initialSnapshot),this._frame=0,this._space}get space(){if(this._space==null)throw new Error("Player: call restore() before reading space");return this._space}get frame(){return this._frame}get frameCount(){return this._replay.frameCount}get finished(){return this._frame>=this._replay.frameCount}get replay(){return this._replay}get applyInput(){return this._applyInput}set applyInput(t){this._applyInput=t;}step(){if(this._space==null)throw new Error("Player: call restore() before step()");if(this._frame>=this._replay.frameCount)throw new Error(`Player: already at end of replay (frame ${this._frame}/${this._replay.frameCount})`);let t=I(this._replay.inputs,this._frame);t!=null&&this._applyInput!=null&&this._applyInput(t.payload,this._space,this._frame),this._space.step(this._dt,this._velocityIterations,this._positionIterations),this._frame++;}stepTo(t){if(!Number.isFinite(t)||t<0||t>this._replay.frameCount)throw new Error(`Player: target frame ${t} out of range [0, ${this._replay.frameCount}]`);if(this._space==null&&this.restore(),t<this._frame){let e=S(this._replay.keyframes,t);e!=null?(this._space=chunkQ2WPJQGU_cjs.c(e.snapshot),this._frame=e.frame):this.restore();}for(;this._frame<t;)this.step();}};function I(r,t){let e=0,i=r.length-1;for(;e<=i;){let a=e+i>>>1,o=r[a].frame;if(o===t)return r[a];o<t?e=a+1:i=a-1;}return null}function S(r,t){let e=0,i=r.length-1,a=null;for(;e<=i;){let o=e+i>>>1,n=r[o];n.frame<=t?(a=n,e=o+1):i=o-1;}return a}var R=1380994137,T=new TextEncoder,E=new TextDecoder;function U(r){let t=[];for(let s of r.inputs){let u=JSON.stringify(s.payload);t.push({frame:s.frame,bytes:T.encode(u??"null")});}let e=14+r.initialSnapshot.byteLength;e+=4;for(let s of t)e+=8+s.bytes.byteLength;e+=4;for(let s of r.keyframes)e+=8+s.snapshot.byteLength;let i=new ArrayBuffer(e),a=new DataView(i),o=new Uint8Array(i),n=0;a.setUint32(n,R,false),n+=4,a.setUint16(n,r.version,true),n+=2,a.setUint32(n,r.frameCount,true),n+=4,a.setUint32(n,r.initialSnapshot.byteLength,true),n+=4,o.set(r.initialSnapshot,n),n+=r.initialSnapshot.byteLength,a.setUint32(n,t.length,true),n+=4;for(let s of t)a.setUint32(n,s.frame,true),n+=4,a.setUint32(n,s.bytes.byteLength,true),n+=4,o.set(s.bytes,n),n+=s.bytes.byteLength;a.setUint32(n,r.keyframes.length,true),n+=4;for(let s of r.keyframes)a.setUint32(n,s.frame,true),n+=4,a.setUint32(n,s.snapshot.byteLength,true),n+=4,o.set(s.snapshot,n),n+=s.snapshot.byteLength;return o}function k(r){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),e=0,i=t.getUint32(e,false);if(e+=4,i!==R)throw new Error(`decodeReplay: invalid magic 0x${i.toString(16).padStart(8,"0")} (expected 0x${R.toString(16)})`);let a=t.getUint16(e,true);if(e+=2,a!==f)throw new Error(`decodeReplay: unsupported version ${a} (expected ${f})`);let o=t.getUint32(e,true);e+=4;let n=t.getUint32(e,true);e+=4;let s=r.slice(e,e+n);e+=n;let u=t.getUint32(e,true);e+=4;let b=new Array(u);for(let p=0;p<u;p++){let m=t.getUint32(e,true);e+=4;let l=t.getUint32(e,true);e+=4;let y=E.decode(r.subarray(e,e+l));e+=l,b[p]={frame:m,payload:JSON.parse(y)};}let g=t.getUint32(e,true);e+=4;let w=new Array(g);for(let p=0;p<g;p++){let m=t.getUint32(e,true);e+=4;let l=t.getUint32(e,true);e+=4;let y=r.slice(e,e+l);e+=l,w[p]={frame:m,snapshot:y};}return {version:a,initialSnapshot:s,inputs:b,keyframes:w,frameCount:o}}function A(r){let t=[];return r==null?{ok:false,warnings:["space is null"]}:(r.deterministic||t.push("space.deterministic is false \u2014 replays will drift from the recording. Set space.deterministic = true."),{ok:t.length===0,warnings:t})}exports.Player=d;exports.REPLAY_VERSION=f;exports.Recorder=_;exports.decodeReplay=k;exports.encodeReplay=U;exports.validateDeterministicConfig=A;//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,2 +1,2 @@
1
- import {b,c}from'../chunk-GPGT7DYQ.js';import'../chunk-263GQ5UK.js';var _=class{constructor(t,e={}){this._inputs=[];this._keyframes=[];this._frame=0;this._finished=false;if(t==null)throw new Error("Recorder: space is required");let i=e.keyframeEvery;if(i!=null&&(!Number.isFinite(i)||i<0||(i|0)!==i))throw new Error(`Recorder: keyframeEvery must be a non-negative integer (got ${i})`);this._space=t,this._keyframeEvery=i??60,this._initialSnapshot=b(t);}get frame(){return this._frame}get finished(){return this._finished}recordFrame(t){if(this._finished)throw new Error("Recorder: cannot record after finish()");if(this._keyframeEvery>0&&this._frame>0&&this._frame%this._keyframeEvery===0&&this._keyframes.push({frame:this._frame,snapshot:b(this._space)}),t!=null){let e=v(t);this._inputs.push({frame:this._frame,payload:e});}this._frame++;}finish(){return this._finished=true,{version:f,initialSnapshot:this._initialSnapshot,inputs:this._inputs.slice(),keyframes:this._keyframes.slice(),frameCount:this._frame}}},f=1;function v(r){let t=typeof r;return r===null||t==="number"||t==="string"||t==="boolean"?r:JSON.parse(JSON.stringify(r))}var d=class{constructor(t,e=null,i={}){this._space=null;this._frame=0;if(t==null)throw new Error("Player: replay is required");this._replay=t,this._applyInput=e,this._dt=i.dt??1/60,this._velocityIterations=i.velocityIterations??8,this._positionIterations=i.positionIterations??3;}restore(){return this._space=c(this._replay.initialSnapshot),this._frame=0,this._space}get space(){if(this._space==null)throw new Error("Player: call restore() before reading space");return this._space}get frame(){return this._frame}get frameCount(){return this._replay.frameCount}get finished(){return this._frame>=this._replay.frameCount}get replay(){return this._replay}get applyInput(){return this._applyInput}set applyInput(t){this._applyInput=t;}step(){if(this._space==null)throw new Error("Player: call restore() before step()");if(this._frame>=this._replay.frameCount)throw new Error(`Player: already at end of replay (frame ${this._frame}/${this._replay.frameCount})`);let t=I(this._replay.inputs,this._frame);t!=null&&this._applyInput!=null&&this._applyInput(t.payload,this._space,this._frame),this._space.step(this._dt,this._velocityIterations,this._positionIterations),this._frame++;}stepTo(t){if(!Number.isFinite(t)||t<0||t>this._replay.frameCount)throw new Error(`Player: target frame ${t} out of range [0, ${this._replay.frameCount}]`);if(this._space==null&&this.restore(),t<this._frame){let e=S(this._replay.keyframes,t);e!=null?(this._space=c(e.snapshot),this._frame=e.frame):this.restore();}for(;this._frame<t;)this.step();}};function I(r,t){let e=0,i=r.length-1;for(;e<=i;){let a=e+i>>>1,o=r[a].frame;if(o===t)return r[a];o<t?e=a+1:i=a-1;}return null}function S(r,t){let e=0,i=r.length-1,a=null;for(;e<=i;){let o=e+i>>>1,n=r[o];n.frame<=t?(a=n,e=o+1):i=o-1;}return a}var R=1380994137,T=new TextEncoder,E=new TextDecoder;function U(r){let t=[];for(let s of r.inputs){let u=JSON.stringify(s.payload);t.push({frame:s.frame,bytes:T.encode(u??"null")});}let e=14+r.initialSnapshot.byteLength;e+=4;for(let s of t)e+=8+s.bytes.byteLength;e+=4;for(let s of r.keyframes)e+=8+s.snapshot.byteLength;let i=new ArrayBuffer(e),a=new DataView(i),o=new Uint8Array(i),n=0;a.setUint32(n,R,false),n+=4,a.setUint16(n,r.version,true),n+=2,a.setUint32(n,r.frameCount,true),n+=4,a.setUint32(n,r.initialSnapshot.byteLength,true),n+=4,o.set(r.initialSnapshot,n),n+=r.initialSnapshot.byteLength,a.setUint32(n,t.length,true),n+=4;for(let s of t)a.setUint32(n,s.frame,true),n+=4,a.setUint32(n,s.bytes.byteLength,true),n+=4,o.set(s.bytes,n),n+=s.bytes.byteLength;a.setUint32(n,r.keyframes.length,true),n+=4;for(let s of r.keyframes)a.setUint32(n,s.frame,true),n+=4,a.setUint32(n,s.snapshot.byteLength,true),n+=4,o.set(s.snapshot,n),n+=s.snapshot.byteLength;return o}function k(r){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),e=0,i=t.getUint32(e,false);if(e+=4,i!==R)throw new Error(`decodeReplay: invalid magic 0x${i.toString(16).padStart(8,"0")} (expected 0x${R.toString(16)})`);let a=t.getUint16(e,true);if(e+=2,a!==f)throw new Error(`decodeReplay: unsupported version ${a} (expected ${f})`);let o=t.getUint32(e,true);e+=4;let n=t.getUint32(e,true);e+=4;let s=r.slice(e,e+n);e+=n;let u=t.getUint32(e,true);e+=4;let b=new Array(u);for(let p=0;p<u;p++){let m=t.getUint32(e,true);e+=4;let l=t.getUint32(e,true);e+=4;let y=E.decode(r.subarray(e,e+l));e+=l,b[p]={frame:m,payload:JSON.parse(y)};}let g=t.getUint32(e,true);e+=4;let w=new Array(g);for(let p=0;p<g;p++){let m=t.getUint32(e,true);e+=4;let l=t.getUint32(e,true);e+=4;let y=r.slice(e,e+l);e+=l,w[p]={frame:m,snapshot:y};}return {version:a,initialSnapshot:s,inputs:b,keyframes:w,frameCount:o}}function A(r){let t=[];return r==null?{ok:false,warnings:["space is null"]}:(r.deterministic||t.push("space.deterministic is false \u2014 replays will drift from the recording. Set space.deterministic = true."),{ok:t.length===0,warnings:t})}export{d as Player,f as REPLAY_VERSION,_ as Recorder,k as decodeReplay,U as encodeReplay,A as validateDeterministicConfig};//# sourceMappingURL=index.js.map
1
+ import {b,c}from'../chunk-N7HIFDFT.js';import'../chunk-BARGM4ZO.js';var _=class{constructor(t,e={}){this._inputs=[];this._keyframes=[];this._frame=0;this._finished=false;if(t==null)throw new Error("Recorder: space is required");let i=e.keyframeEvery;if(i!=null&&(!Number.isFinite(i)||i<0||(i|0)!==i))throw new Error(`Recorder: keyframeEvery must be a non-negative integer (got ${i})`);this._space=t,this._keyframeEvery=i??60,this._initialSnapshot=b(t);}get frame(){return this._frame}get finished(){return this._finished}recordFrame(t){if(this._finished)throw new Error("Recorder: cannot record after finish()");if(this._keyframeEvery>0&&this._frame>0&&this._frame%this._keyframeEvery===0&&this._keyframes.push({frame:this._frame,snapshot:b(this._space)}),t!=null){let e=v(t);this._inputs.push({frame:this._frame,payload:e});}this._frame++;}finish(){return this._finished=true,{version:f,initialSnapshot:this._initialSnapshot,inputs:this._inputs.slice(),keyframes:this._keyframes.slice(),frameCount:this._frame}}},f=1;function v(r){let t=typeof r;return r===null||t==="number"||t==="string"||t==="boolean"?r:JSON.parse(JSON.stringify(r))}var d=class{constructor(t,e=null,i={}){this._space=null;this._frame=0;if(t==null)throw new Error("Player: replay is required");this._replay=t,this._applyInput=e,this._dt=i.dt??1/60,this._velocityIterations=i.velocityIterations??8,this._positionIterations=i.positionIterations??3;}restore(){return this._space=c(this._replay.initialSnapshot),this._frame=0,this._space}get space(){if(this._space==null)throw new Error("Player: call restore() before reading space");return this._space}get frame(){return this._frame}get frameCount(){return this._replay.frameCount}get finished(){return this._frame>=this._replay.frameCount}get replay(){return this._replay}get applyInput(){return this._applyInput}set applyInput(t){this._applyInput=t;}step(){if(this._space==null)throw new Error("Player: call restore() before step()");if(this._frame>=this._replay.frameCount)throw new Error(`Player: already at end of replay (frame ${this._frame}/${this._replay.frameCount})`);let t=I(this._replay.inputs,this._frame);t!=null&&this._applyInput!=null&&this._applyInput(t.payload,this._space,this._frame),this._space.step(this._dt,this._velocityIterations,this._positionIterations),this._frame++;}stepTo(t){if(!Number.isFinite(t)||t<0||t>this._replay.frameCount)throw new Error(`Player: target frame ${t} out of range [0, ${this._replay.frameCount}]`);if(this._space==null&&this.restore(),t<this._frame){let e=S(this._replay.keyframes,t);e!=null?(this._space=c(e.snapshot),this._frame=e.frame):this.restore();}for(;this._frame<t;)this.step();}};function I(r,t){let e=0,i=r.length-1;for(;e<=i;){let a=e+i>>>1,o=r[a].frame;if(o===t)return r[a];o<t?e=a+1:i=a-1;}return null}function S(r,t){let e=0,i=r.length-1,a=null;for(;e<=i;){let o=e+i>>>1,n=r[o];n.frame<=t?(a=n,e=o+1):i=o-1;}return a}var R=1380994137,T=new TextEncoder,E=new TextDecoder;function U(r){let t=[];for(let s of r.inputs){let u=JSON.stringify(s.payload);t.push({frame:s.frame,bytes:T.encode(u??"null")});}let e=14+r.initialSnapshot.byteLength;e+=4;for(let s of t)e+=8+s.bytes.byteLength;e+=4;for(let s of r.keyframes)e+=8+s.snapshot.byteLength;let i=new ArrayBuffer(e),a=new DataView(i),o=new Uint8Array(i),n=0;a.setUint32(n,R,false),n+=4,a.setUint16(n,r.version,true),n+=2,a.setUint32(n,r.frameCount,true),n+=4,a.setUint32(n,r.initialSnapshot.byteLength,true),n+=4,o.set(r.initialSnapshot,n),n+=r.initialSnapshot.byteLength,a.setUint32(n,t.length,true),n+=4;for(let s of t)a.setUint32(n,s.frame,true),n+=4,a.setUint32(n,s.bytes.byteLength,true),n+=4,o.set(s.bytes,n),n+=s.bytes.byteLength;a.setUint32(n,r.keyframes.length,true),n+=4;for(let s of r.keyframes)a.setUint32(n,s.frame,true),n+=4,a.setUint32(n,s.snapshot.byteLength,true),n+=4,o.set(s.snapshot,n),n+=s.snapshot.byteLength;return o}function k(r){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),e=0,i=t.getUint32(e,false);if(e+=4,i!==R)throw new Error(`decodeReplay: invalid magic 0x${i.toString(16).padStart(8,"0")} (expected 0x${R.toString(16)})`);let a=t.getUint16(e,true);if(e+=2,a!==f)throw new Error(`decodeReplay: unsupported version ${a} (expected ${f})`);let o=t.getUint32(e,true);e+=4;let n=t.getUint32(e,true);e+=4;let s=r.slice(e,e+n);e+=n;let u=t.getUint32(e,true);e+=4;let b=new Array(u);for(let p=0;p<u;p++){let m=t.getUint32(e,true);e+=4;let l=t.getUint32(e,true);e+=4;let y=E.decode(r.subarray(e,e+l));e+=l,b[p]={frame:m,payload:JSON.parse(y)};}let g=t.getUint32(e,true);e+=4;let w=new Array(g);for(let p=0;p<g;p++){let m=t.getUint32(e,true);e+=4;let l=t.getUint32(e,true);e+=4;let y=r.slice(e,e+l);e+=l,w[p]={frame:m,snapshot:y};}return {version:a,initialSnapshot:s,inputs:b,keyframes:w,frameCount:o}}function A(r){let t=[];return r==null?{ok:false,warnings:["space is null"]}:(r.deterministic||t.push("space.deterministic is false \u2014 replays will drift from the recording. Set space.deterministic = true."),{ok:t.length===0,warnings:t})}export{d as Player,f as REPLAY_VERSION,_ as Recorder,k as decodeReplay,U as encodeReplay,A as validateDeterministicConfig};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkCA2F5ISB_cjs=require('../chunk-CA2F5ISB.cjs'),chunkHQH77APJ_cjs=require('../chunk-HQH77APJ.cjs');var J=1;function s(t){return {x:t.x,y:t.y}}function Q(t){if(t==null)return null;try{let a=JSON.stringify(t);return a==="{}"?null:JSON.parse(a)}catch{return null}}function it(t){return {elasticity:t.elasticity,dynamicFriction:t.dynamicFriction,staticFriction:t.staticFriction,density:t.density,rollingFriction:t.rollingFriction}}function st(t){return {collisionGroup:t.collisionGroup,collisionMask:t.collisionMask,sensorGroup:t.sensorGroup,sensorMask:t.sensorMask,fluidGroup:t.fluidGroup,fluidMask:t.fluidMask}}function lt(t){if(t==null)return null;let a=t.gravity;return {density:t.density,viscosity:t.viscosity,gravity:a!=null?s(a):null}}function ct(t){let a=it(t.material),n=st(t.filter),e=t.fluidEnabled,o=e?lt(t.fluidProperties):null,l=t.sensorEnabled;if(t.isCircle()){let c=t,r=t.localCOM;return {type:"circle",radius:c.radius,localCOM:s(r),material:a,filter:n,sensorEnabled:l,fluidEnabled:e,fluidProperties:o}}else if(t.isCapsule()){let c=t,r=t.localCOM;return {type:"capsule",width:c.width,height:c.height,localCOM:s(r),material:a,filter:n,sensorEnabled:l,fluidEnabled:e,fluidProperties:o}}else {let r=t.localVerts,m=[],u=r.length;for(let b=0;b<u;b++)m.push(s(r.at(b)));return {type:"polygon",localVerts:m,material:a,filter:n,sensorEnabled:l,fluidEnabled:e,fluidProperties:o}}}var ut={1:"STATIC",2:"DYNAMIC",3:"KINEMATIC"},pt={0:"DEFAULT",1:"FIXED",2:"FIXED_GROUP"},mt={0:"DEFAULT",1:"FIXED",2:"FIXED_GROUP"},Dt={0:"DEFAULT",1:"FIXED",2:"SCALED"};function yt(t,a){let n=t.zpp_inner,e=pt[n.massMode]??"DEFAULT",o=mt[n.inertiaMode]??"DEFAULT",l=Dt[n.gravMassMode]??"DEFAULT",c=[],r=t.shapes,m=r.length;for(let u=0;u<m;u++)c.push(ct(r.at(u)));return {id:a,type:ut[n.type]??"DYNAMIC",position:s(t.position),rotation:t.rotation,velocity:s(t.velocity),angularVel:t.angularVel,kinematicVel:s(t.kinematicVel),kinAngVel:t.kinAngVel,surfaceVel:s(t.surfaceVel),force:s(t.force),torque:n.type===2?t.torque:0,massMode:e,mass:e==="FIXED"?n.cmass:null,inertiaMode:o,inertia:o==="FIXED"?n.cinertia:null,gravMassMode:l,gravMassScale:n.gravMassScale,allowMovement:t.allowMovement,allowRotation:t.allowRotation,bullet:t.isBullet,shapes:c,userData:Q(n.userData)}}function h(t,a,n,e){let o=t.zpp_inner,l=n!=null?a.get(n.zpp_inner.id)??null:null,c=e!=null?a.get(e.zpp_inner.id)??null:null;return {body1Id:l,body2Id:c,active:o.active,ignore:o.ignore,stiff:o.stiff,frequency:o.frequency,damping:o.damping,maxForce:o.maxForce,maxError:o.maxError,breakUnderForce:o.breakUnderForce,breakUnderError:o.breakUnderError,removeOnBreak:o.removeOnBreak,userData:Q(o.userData)}}function ft(t,a){switch(t.constructor?.name??""){case "PivotJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"PivotJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2)}}case "DistanceJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"DistanceJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),jointMin:e.jointMin,jointMax:e.jointMax}}case "AngleJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"AngleJoint",jointMin:e.jointMin,jointMax:e.jointMax,ratio:e.ratio}}case "MotorJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"MotorJoint",rate:e.rate,ratio:e.ratio}}case "LineJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"LineJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),direction:s(e.direction),jointMin:e.jointMin,jointMax:e.jointMax}}case "PulleyJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"PulleyJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),anchor3:s(e.anchor3),anchor4:s(e.anchor4),jointMin:e.jointMin,jointMax:e.jointMax,ratio:e.ratio}}case "WeldJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"WeldJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),phase:e.phase}}default:return null}}function dt(t){let a=[],n=new Map,e=new Map;function o(i){let y=i.zpp_inner.id;if(e.has(y))return;let D=a.length;n.set(i,D),e.set(y,D),a.push(yt(i,D));}let l=t.bodies,c=l.length;for(let i=0;i<c;i++)o(l.at(i));let r=t.compounds,m=r.length;for(let i=0;i<m;i++){let D=r.at(i).bodies,C=D.length;for(let f=0;f<C;f++)o(D.at(f));}let u=[],b=new Map;function I(i){if(b.has(i))return;let y=ft(i,e);y!=null&&(b.set(i,u.length),u.push(y));}let x=t.constraints,Z=x.length;for(let i=0;i<Z;i++)I(x.at(i));for(let i=0;i<m;i++){let D=r.at(i).constraints,C=D.length;for(let f=0;f<C;f++)I(D.at(f));}let V=[];for(let i=0;i<m;i++){let y=r.at(i),D=[],C=y.bodies,f=C.length;for(let M=0;M<f;M++){let F=C.at(M),S=n.get(F);S!=null&&D.push(S);}let B=[],w=y.constraints,nt=w.length;for(let M=0;M<nt;M++){let F=w.at(M),S=b.get(F);S!=null&&B.push(S);}V.push({bodyIds:D,constraintIndices:B,childIndices:[]});}let tt=t.zpp_inner.bphase.is_sweep?"SWEEP_AND_PRUNE":"DYNAMIC_AABB_TREE",et=t.gravity;return {version:1,gravity:s(et),worldLinearDrag:t.worldLinearDrag,worldAngularDrag:t.worldAngularDrag,sortContacts:t.sortContacts,deterministic:t.deterministic,broadphase:tt,bodies:a,constraints:u,compounds:V}}function d(t){return chunkHQH77APJ_cjs.I.get(t.x,t.y)}function p(t){return chunkHQH77APJ_cjs.I.weak(t.x,t.y)}function bt(t){return new chunkHQH77APJ_cjs.ca(t.elasticity,t.dynamicFriction,t.staticFriction,t.density,t.rollingFriction)}function Mt(t){let a=new chunkHQH77APJ_cjs.ha;return a.collisionGroup=t.collisionGroup,a.collisionMask=t.collisionMask,a.sensorGroup=t.sensorGroup,a.sensorMask=t.sensorMask,a.fluidGroup=t.fluidGroup,a.fluidMask=t.fluidMask,a}function ht(t){let a=new chunkHQH77APJ_cjs.U(t.density,t.viscosity);return t.gravity!=null&&(a.gravity=d(t.gravity)),a}function gt(t){let a=bt(t.material),n=Mt(t.filter),e;if(t.type==="circle"){let o=d(t.localCOM);e=new chunkHQH77APJ_cjs.ga(t.radius,o,a,n);}else if(t.type==="capsule"){let o=d(t.localCOM);e=new chunkHQH77APJ_cjs.ja(t.width,t.height,o,a,n);}else {let o=t.localVerts.map(l=>d(l));e=new chunkHQH77APJ_cjs.ia(o,a,n);}return e.sensorEnabled=t.sensorEnabled,e.fluidEnabled=t.fluidEnabled,t.fluidEnabled&&t.fluidProperties!=null&&(e.fluidProperties=ht(t.fluidProperties)),e}function Ct(t){let a=t.type==="STATIC"?chunkHQH77APJ_cjs.aa.STATIC:t.type==="KINEMATIC"?chunkHQH77APJ_cjs.aa.KINEMATIC:chunkHQH77APJ_cjs.aa.DYNAMIC,n=new chunkHQH77APJ_cjs.$(a,p(t.position));n.rotation=t.rotation,t.type!=="STATIC"&&(n.velocity=d(t.velocity),n.angularVel=t.angularVel),n.kinematicVel=d(t.kinematicVel),n.kinAngVel=t.kinAngVel,n.surfaceVel=d(t.surfaceVel),t.type==="DYNAMIC"&&(n.force=d(t.force),n.torque=t.torque),t.massMode==="FIXED"&&t.mass!=null?n.mass=t.mass:t.massMode==="DEFAULT"&&(n.massMode=chunkHQH77APJ_cjs.fa.DEFAULT),t.inertiaMode==="FIXED"&&t.inertia!=null?n.inertia=t.inertia:t.inertiaMode==="DEFAULT"&&(n.inertiaMode=chunkHQH77APJ_cjs.ea.DEFAULT),t.gravMassMode==="SCALED"?(n.gravMassMode=chunkHQH77APJ_cjs.da.SCALED,n.gravMassScale=t.gravMassScale):t.gravMassMode==="FIXED"&&(n.gravMassMode=chunkHQH77APJ_cjs.da.FIXED),n.allowMovement=t.allowMovement,n.allowRotation=t.allowRotation,n.isBullet=t.bullet;for(let e of t.shapes)gt(e).body=n;return t.userData!=null&&Object.assign(n.userData,t.userData),n}function g(t,a){t.active=a.active,t.ignore=a.ignore,t.stiff=a.stiff,t.frequency=a.frequency,t.damping=a.damping,t.maxForce=a.maxForce,t.maxError=a.maxError,t.breakUnderForce=a.breakUnderForce,t.breakUnderError=a.breakUnderError,t.removeOnBreak=a.removeOnBreak,a.userData!=null&&Object.assign(t.userData,a.userData);}function St(t,a){let n=t.body1Id!=null?a[t.body1Id]??null:null,e=t.body2Id!=null?a[t.body2Id]??null:null;switch(t.type){case "PivotJoint":{let o=new chunkHQH77APJ_cjs.qa(n,e,p(t.anchor1),p(t.anchor2));return g(o,t),o}case "DistanceJoint":{let o=new chunkHQH77APJ_cjs.na(n,e,p(t.anchor1),p(t.anchor2),t.jointMin,t.jointMax);return g(o,t),o}case "AngleJoint":{let o=new chunkHQH77APJ_cjs.ma(n,e,t.jointMin,t.jointMax,t.ratio);return g(o,t),o}case "MotorJoint":{let o=new chunkHQH77APJ_cjs.pa(n,e,t.rate,t.ratio);return g(o,t),o}case "LineJoint":{let o=new chunkHQH77APJ_cjs.oa(n,e,p(t.anchor1),p(t.anchor2),p(t.direction),t.jointMin,t.jointMax);return g(o,t),o}case "PulleyJoint":{let o=new chunkHQH77APJ_cjs.ra(n,e,null,null,p(t.anchor1),p(t.anchor2),p(t.anchor3),p(t.anchor4),t.jointMin,t.jointMax,t.ratio);return g(o,t),o}case "WeldJoint":{let o=new chunkHQH77APJ_cjs.sa(n,e,p(t.anchor1),p(t.anchor2),t.phase);return g(o,t),o}}}function Et(t){if(t.version!==1)throw new Error(`nape-js serialization: unsupported snapshot version ${t.version} (expected ${1})`);let a=t.broadphase==="SWEEP_AND_PRUNE"?chunkHQH77APJ_cjs.ka.SWEEP_AND_PRUNE:chunkHQH77APJ_cjs.ka.DYNAMIC_AABB_TREE,n=new chunkHQH77APJ_cjs.Y(p(t.gravity),a);n.worldLinearDrag=t.worldLinearDrag,n.worldAngularDrag=t.worldAngularDrag,n.sortContacts=t.sortContacts,n.deterministic=t.deterministic??false;let e=t.bodies.map(Ct),o=t.constraints.map(r=>St(r,e)),l=new Set,c=new Set;for(let r of t.compounds){let m=new chunkHQH77APJ_cjs.ba;for(let u of r.bodyIds)e[u].compound=m,l.add(u);for(let u of r.constraintIndices)o[u].compound=m,c.add(u);m.space=n;}for(let r=0;r<e.length;r++)l.has(r)||(e[r].space=n);for(let r=0;r<o.length;r++)c.has(r)||(o[r].space=n);return n}Object.defineProperty(exports,"BINARY_SNAPSHOT_VERSION",{enumerable:true,get:function(){return chunkCA2F5ISB_cjs.a}});Object.defineProperty(exports,"spaceFromBinary",{enumerable:true,get:function(){return chunkCA2F5ISB_cjs.c}});Object.defineProperty(exports,"spaceToBinary",{enumerable:true,get:function(){return chunkCA2F5ISB_cjs.b}});exports.SNAPSHOT_VERSION=J;exports.spaceFromJSON=Et;exports.spaceToJSON=dt;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var chunkQ2WPJQGU_cjs=require('../chunk-Q2WPJQGU.cjs'),chunkWB53BIOZ_cjs=require('../chunk-WB53BIOZ.cjs');var J=1;function s(t){return {x:t.x,y:t.y}}function Q(t){if(t==null)return null;try{let a=JSON.stringify(t);return a==="{}"?null:JSON.parse(a)}catch{return null}}function it(t){return {elasticity:t.elasticity,dynamicFriction:t.dynamicFriction,staticFriction:t.staticFriction,density:t.density,rollingFriction:t.rollingFriction}}function st(t){return {collisionGroup:t.collisionGroup,collisionMask:t.collisionMask,sensorGroup:t.sensorGroup,sensorMask:t.sensorMask,fluidGroup:t.fluidGroup,fluidMask:t.fluidMask}}function lt(t){if(t==null)return null;let a=t.gravity;return {density:t.density,viscosity:t.viscosity,gravity:a!=null?s(a):null}}function ct(t){let a=it(t.material),n=st(t.filter),e=t.fluidEnabled,o=e?lt(t.fluidProperties):null,l=t.sensorEnabled;if(t.isCircle()){let c=t,r=t.localCOM;return {type:"circle",radius:c.radius,localCOM:s(r),material:a,filter:n,sensorEnabled:l,fluidEnabled:e,fluidProperties:o}}else if(t.isCapsule()){let c=t,r=t.localCOM;return {type:"capsule",width:c.width,height:c.height,localCOM:s(r),material:a,filter:n,sensorEnabled:l,fluidEnabled:e,fluidProperties:o}}else {let r=t.localVerts,m=[],u=r.length;for(let b=0;b<u;b++)m.push(s(r.at(b)));return {type:"polygon",localVerts:m,material:a,filter:n,sensorEnabled:l,fluidEnabled:e,fluidProperties:o}}}var ut={1:"STATIC",2:"DYNAMIC",3:"KINEMATIC"},pt={0:"DEFAULT",1:"FIXED",2:"FIXED_GROUP"},mt={0:"DEFAULT",1:"FIXED",2:"FIXED_GROUP"},Dt={0:"DEFAULT",1:"FIXED",2:"SCALED"};function yt(t,a){let n=t.zpp_inner,e=pt[n.massMode]??"DEFAULT",o=mt[n.inertiaMode]??"DEFAULT",l=Dt[n.gravMassMode]??"DEFAULT",c=[],r=t.shapes,m=r.length;for(let u=0;u<m;u++)c.push(ct(r.at(u)));return {id:a,type:ut[n.type]??"DYNAMIC",position:s(t.position),rotation:t.rotation,velocity:s(t.velocity),angularVel:t.angularVel,kinematicVel:s(t.kinematicVel),kinAngVel:t.kinAngVel,surfaceVel:s(t.surfaceVel),force:s(t.force),torque:n.type===2?t.torque:0,massMode:e,mass:e==="FIXED"?n.cmass:null,inertiaMode:o,inertia:o==="FIXED"?n.cinertia:null,gravMassMode:l,gravMassScale:n.gravMassScale,allowMovement:t.allowMovement,allowRotation:t.allowRotation,bullet:t.isBullet,shapes:c,userData:Q(n.userData)}}function h(t,a,n,e){let o=t.zpp_inner,l=n!=null?a.get(n.zpp_inner.id)??null:null,c=e!=null?a.get(e.zpp_inner.id)??null:null;return {body1Id:l,body2Id:c,active:o.active,ignore:o.ignore,stiff:o.stiff,frequency:o.frequency,damping:o.damping,maxForce:o.maxForce,maxError:o.maxError,breakUnderForce:o.breakUnderForce,breakUnderError:o.breakUnderError,removeOnBreak:o.removeOnBreak,userData:Q(o.userData)}}function ft(t,a){switch(t.constructor?.name??""){case "PivotJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"PivotJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2)}}case "DistanceJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"DistanceJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),jointMin:e.jointMin,jointMax:e.jointMax}}case "AngleJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"AngleJoint",jointMin:e.jointMin,jointMax:e.jointMax,ratio:e.ratio}}case "MotorJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"MotorJoint",rate:e.rate,ratio:e.ratio}}case "LineJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"LineJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),direction:s(e.direction),jointMin:e.jointMin,jointMax:e.jointMax}}case "PulleyJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"PulleyJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),anchor3:s(e.anchor3),anchor4:s(e.anchor4),jointMin:e.jointMin,jointMax:e.jointMax,ratio:e.ratio}}case "WeldJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"WeldJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),phase:e.phase}}default:return null}}function dt(t){let a=[],n=new Map,e=new Map;function o(i){let y=i.zpp_inner.id;if(e.has(y))return;let D=a.length;n.set(i,D),e.set(y,D),a.push(yt(i,D));}let l=t.bodies,c=l.length;for(let i=0;i<c;i++)o(l.at(i));let r=t.compounds,m=r.length;for(let i=0;i<m;i++){let D=r.at(i).bodies,C=D.length;for(let f=0;f<C;f++)o(D.at(f));}let u=[],b=new Map;function I(i){if(b.has(i))return;let y=ft(i,e);y!=null&&(b.set(i,u.length),u.push(y));}let x=t.constraints,Z=x.length;for(let i=0;i<Z;i++)I(x.at(i));for(let i=0;i<m;i++){let D=r.at(i).constraints,C=D.length;for(let f=0;f<C;f++)I(D.at(f));}let V=[];for(let i=0;i<m;i++){let y=r.at(i),D=[],C=y.bodies,f=C.length;for(let M=0;M<f;M++){let F=C.at(M),S=n.get(F);S!=null&&D.push(S);}let B=[],w=y.constraints,nt=w.length;for(let M=0;M<nt;M++){let F=w.at(M),S=b.get(F);S!=null&&B.push(S);}V.push({bodyIds:D,constraintIndices:B,childIndices:[]});}let tt=t.zpp_inner.bphase.is_sweep?"SWEEP_AND_PRUNE":"DYNAMIC_AABB_TREE",et=t.gravity;return {version:1,gravity:s(et),worldLinearDrag:t.worldLinearDrag,worldAngularDrag:t.worldAngularDrag,sortContacts:t.sortContacts,deterministic:t.deterministic,broadphase:tt,bodies:a,constraints:u,compounds:V}}function d(t){return chunkWB53BIOZ_cjs.I.get(t.x,t.y)}function p(t){return chunkWB53BIOZ_cjs.I.weak(t.x,t.y)}function bt(t){return new chunkWB53BIOZ_cjs.ca(t.elasticity,t.dynamicFriction,t.staticFriction,t.density,t.rollingFriction)}function Mt(t){let a=new chunkWB53BIOZ_cjs.ha;return a.collisionGroup=t.collisionGroup,a.collisionMask=t.collisionMask,a.sensorGroup=t.sensorGroup,a.sensorMask=t.sensorMask,a.fluidGroup=t.fluidGroup,a.fluidMask=t.fluidMask,a}function ht(t){let a=new chunkWB53BIOZ_cjs.U(t.density,t.viscosity);return t.gravity!=null&&(a.gravity=d(t.gravity)),a}function gt(t){let a=bt(t.material),n=Mt(t.filter),e;if(t.type==="circle"){let o=d(t.localCOM);e=new chunkWB53BIOZ_cjs.ga(t.radius,o,a,n);}else if(t.type==="capsule"){let o=d(t.localCOM);e=new chunkWB53BIOZ_cjs.ja(t.width,t.height,o,a,n);}else {let o=t.localVerts.map(l=>d(l));e=new chunkWB53BIOZ_cjs.ia(o,a,n);}return e.sensorEnabled=t.sensorEnabled,e.fluidEnabled=t.fluidEnabled,t.fluidEnabled&&t.fluidProperties!=null&&(e.fluidProperties=ht(t.fluidProperties)),e}function Ct(t){let a=t.type==="STATIC"?chunkWB53BIOZ_cjs.aa.STATIC:t.type==="KINEMATIC"?chunkWB53BIOZ_cjs.aa.KINEMATIC:chunkWB53BIOZ_cjs.aa.DYNAMIC,n=new chunkWB53BIOZ_cjs.$(a,p(t.position));n.rotation=t.rotation,t.type!=="STATIC"&&(n.velocity=d(t.velocity),n.angularVel=t.angularVel),n.kinematicVel=d(t.kinematicVel),n.kinAngVel=t.kinAngVel,n.surfaceVel=d(t.surfaceVel),t.type==="DYNAMIC"&&(n.force=d(t.force),n.torque=t.torque),t.massMode==="FIXED"&&t.mass!=null?n.mass=t.mass:t.massMode==="DEFAULT"&&(n.massMode=chunkWB53BIOZ_cjs.fa.DEFAULT),t.inertiaMode==="FIXED"&&t.inertia!=null?n.inertia=t.inertia:t.inertiaMode==="DEFAULT"&&(n.inertiaMode=chunkWB53BIOZ_cjs.ea.DEFAULT),t.gravMassMode==="SCALED"?(n.gravMassMode=chunkWB53BIOZ_cjs.da.SCALED,n.gravMassScale=t.gravMassScale):t.gravMassMode==="FIXED"&&(n.gravMassMode=chunkWB53BIOZ_cjs.da.FIXED),n.allowMovement=t.allowMovement,n.allowRotation=t.allowRotation,n.isBullet=t.bullet;for(let e of t.shapes)gt(e).body=n;return t.userData!=null&&Object.assign(n.userData,t.userData),n}function g(t,a){t.active=a.active,t.ignore=a.ignore,t.stiff=a.stiff,t.frequency=a.frequency,t.damping=a.damping,t.maxForce=a.maxForce,t.maxError=a.maxError,t.breakUnderForce=a.breakUnderForce,t.breakUnderError=a.breakUnderError,t.removeOnBreak=a.removeOnBreak,a.userData!=null&&Object.assign(t.userData,a.userData);}function St(t,a){let n=t.body1Id!=null?a[t.body1Id]??null:null,e=t.body2Id!=null?a[t.body2Id]??null:null;switch(t.type){case "PivotJoint":{let o=new chunkWB53BIOZ_cjs.ra(n,e,p(t.anchor1),p(t.anchor2));return g(o,t),o}case "DistanceJoint":{let o=new chunkWB53BIOZ_cjs.oa(n,e,p(t.anchor1),p(t.anchor2),t.jointMin,t.jointMax);return g(o,t),o}case "AngleJoint":{let o=new chunkWB53BIOZ_cjs.na(n,e,t.jointMin,t.jointMax,t.ratio);return g(o,t),o}case "MotorJoint":{let o=new chunkWB53BIOZ_cjs.qa(n,e,t.rate,t.ratio);return g(o,t),o}case "LineJoint":{let o=new chunkWB53BIOZ_cjs.pa(n,e,p(t.anchor1),p(t.anchor2),p(t.direction),t.jointMin,t.jointMax);return g(o,t),o}case "PulleyJoint":{let o=new chunkWB53BIOZ_cjs.sa(n,e,null,null,p(t.anchor1),p(t.anchor2),p(t.anchor3),p(t.anchor4),t.jointMin,t.jointMax,t.ratio);return g(o,t),o}case "WeldJoint":{let o=new chunkWB53BIOZ_cjs.ta(n,e,p(t.anchor1),p(t.anchor2),t.phase);return g(o,t),o}}}function Et(t){if(t.version!==1)throw new Error(`nape-js serialization: unsupported snapshot version ${t.version} (expected ${1})`);let a=t.broadphase==="SWEEP_AND_PRUNE"?chunkWB53BIOZ_cjs.ka.SWEEP_AND_PRUNE:chunkWB53BIOZ_cjs.ka.DYNAMIC_AABB_TREE,n=new chunkWB53BIOZ_cjs.Y(p(t.gravity),a);n.worldLinearDrag=t.worldLinearDrag,n.worldAngularDrag=t.worldAngularDrag,n.sortContacts=t.sortContacts,n.deterministic=t.deterministic??false;let e=t.bodies.map(Ct),o=t.constraints.map(r=>St(r,e)),l=new Set,c=new Set;for(let r of t.compounds){let m=new chunkWB53BIOZ_cjs.ba;for(let u of r.bodyIds)e[u].compound=m,l.add(u);for(let u of r.constraintIndices)o[u].compound=m,c.add(u);m.space=n;}for(let r=0;r<e.length;r++)l.has(r)||(e[r].space=n);for(let r=0;r<o.length;r++)c.has(r)||(o[r].space=n);return n}Object.defineProperty(exports,"BINARY_SNAPSHOT_VERSION",{enumerable:true,get:function(){return chunkQ2WPJQGU_cjs.a}});Object.defineProperty(exports,"spaceFromBinary",{enumerable:true,get:function(){return chunkQ2WPJQGU_cjs.c}});Object.defineProperty(exports,"spaceToBinary",{enumerable:true,get:function(){return chunkQ2WPJQGU_cjs.b}});exports.SNAPSHOT_VERSION=J;exports.spaceFromJSON=Et;exports.spaceToJSON=dt;//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,2 +1,2 @@
1
- export{a as BINARY_SNAPSHOT_VERSION,c as spaceFromBinary,b as spaceToBinary}from'../chunk-GPGT7DYQ.js';import {ka,Y,ba,I,aa,$,fa,ea,da,sa,ra,oa,pa,ma,na,qa,ga,ja,ia,ca,ha,U}from'../chunk-263GQ5UK.js';var J=1;function s(t){return {x:t.x,y:t.y}}function Q(t){if(t==null)return null;try{let a=JSON.stringify(t);return a==="{}"?null:JSON.parse(a)}catch{return null}}function it(t){return {elasticity:t.elasticity,dynamicFriction:t.dynamicFriction,staticFriction:t.staticFriction,density:t.density,rollingFriction:t.rollingFriction}}function st(t){return {collisionGroup:t.collisionGroup,collisionMask:t.collisionMask,sensorGroup:t.sensorGroup,sensorMask:t.sensorMask,fluidGroup:t.fluidGroup,fluidMask:t.fluidMask}}function lt(t){if(t==null)return null;let a=t.gravity;return {density:t.density,viscosity:t.viscosity,gravity:a!=null?s(a):null}}function ct(t){let a=it(t.material),n=st(t.filter),e=t.fluidEnabled,o=e?lt(t.fluidProperties):null,l=t.sensorEnabled;if(t.isCircle()){let c=t,r=t.localCOM;return {type:"circle",radius:c.radius,localCOM:s(r),material:a,filter:n,sensorEnabled:l,fluidEnabled:e,fluidProperties:o}}else if(t.isCapsule()){let c=t,r=t.localCOM;return {type:"capsule",width:c.width,height:c.height,localCOM:s(r),material:a,filter:n,sensorEnabled:l,fluidEnabled:e,fluidProperties:o}}else {let r=t.localVerts,m=[],u=r.length;for(let b=0;b<u;b++)m.push(s(r.at(b)));return {type:"polygon",localVerts:m,material:a,filter:n,sensorEnabled:l,fluidEnabled:e,fluidProperties:o}}}var ut={1:"STATIC",2:"DYNAMIC",3:"KINEMATIC"},pt={0:"DEFAULT",1:"FIXED",2:"FIXED_GROUP"},mt={0:"DEFAULT",1:"FIXED",2:"FIXED_GROUP"},Dt={0:"DEFAULT",1:"FIXED",2:"SCALED"};function yt(t,a){let n=t.zpp_inner,e=pt[n.massMode]??"DEFAULT",o=mt[n.inertiaMode]??"DEFAULT",l=Dt[n.gravMassMode]??"DEFAULT",c=[],r=t.shapes,m=r.length;for(let u=0;u<m;u++)c.push(ct(r.at(u)));return {id:a,type:ut[n.type]??"DYNAMIC",position:s(t.position),rotation:t.rotation,velocity:s(t.velocity),angularVel:t.angularVel,kinematicVel:s(t.kinematicVel),kinAngVel:t.kinAngVel,surfaceVel:s(t.surfaceVel),force:s(t.force),torque:n.type===2?t.torque:0,massMode:e,mass:e==="FIXED"?n.cmass:null,inertiaMode:o,inertia:o==="FIXED"?n.cinertia:null,gravMassMode:l,gravMassScale:n.gravMassScale,allowMovement:t.allowMovement,allowRotation:t.allowRotation,bullet:t.isBullet,shapes:c,userData:Q(n.userData)}}function h(t,a,n,e){let o=t.zpp_inner,l=n!=null?a.get(n.zpp_inner.id)??null:null,c=e!=null?a.get(e.zpp_inner.id)??null:null;return {body1Id:l,body2Id:c,active:o.active,ignore:o.ignore,stiff:o.stiff,frequency:o.frequency,damping:o.damping,maxForce:o.maxForce,maxError:o.maxError,breakUnderForce:o.breakUnderForce,breakUnderError:o.breakUnderError,removeOnBreak:o.removeOnBreak,userData:Q(o.userData)}}function ft(t,a){switch(t.constructor?.name??""){case "PivotJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"PivotJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2)}}case "DistanceJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"DistanceJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),jointMin:e.jointMin,jointMax:e.jointMax}}case "AngleJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"AngleJoint",jointMin:e.jointMin,jointMax:e.jointMax,ratio:e.ratio}}case "MotorJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"MotorJoint",rate:e.rate,ratio:e.ratio}}case "LineJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"LineJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),direction:s(e.direction),jointMin:e.jointMin,jointMax:e.jointMax}}case "PulleyJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"PulleyJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),anchor3:s(e.anchor3),anchor4:s(e.anchor4),jointMin:e.jointMin,jointMax:e.jointMax,ratio:e.ratio}}case "WeldJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"WeldJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),phase:e.phase}}default:return null}}function dt(t){let a=[],n=new Map,e=new Map;function o(i){let y=i.zpp_inner.id;if(e.has(y))return;let D=a.length;n.set(i,D),e.set(y,D),a.push(yt(i,D));}let l=t.bodies,c=l.length;for(let i=0;i<c;i++)o(l.at(i));let r=t.compounds,m=r.length;for(let i=0;i<m;i++){let D=r.at(i).bodies,C=D.length;for(let f=0;f<C;f++)o(D.at(f));}let u=[],b=new Map;function I(i){if(b.has(i))return;let y=ft(i,e);y!=null&&(b.set(i,u.length),u.push(y));}let x=t.constraints,Z=x.length;for(let i=0;i<Z;i++)I(x.at(i));for(let i=0;i<m;i++){let D=r.at(i).constraints,C=D.length;for(let f=0;f<C;f++)I(D.at(f));}let V=[];for(let i=0;i<m;i++){let y=r.at(i),D=[],C=y.bodies,f=C.length;for(let M=0;M<f;M++){let F=C.at(M),S=n.get(F);S!=null&&D.push(S);}let B=[],w=y.constraints,nt=w.length;for(let M=0;M<nt;M++){let F=w.at(M),S=b.get(F);S!=null&&B.push(S);}V.push({bodyIds:D,constraintIndices:B,childIndices:[]});}let tt=t.zpp_inner.bphase.is_sweep?"SWEEP_AND_PRUNE":"DYNAMIC_AABB_TREE",et=t.gravity;return {version:1,gravity:s(et),worldLinearDrag:t.worldLinearDrag,worldAngularDrag:t.worldAngularDrag,sortContacts:t.sortContacts,deterministic:t.deterministic,broadphase:tt,bodies:a,constraints:u,compounds:V}}function d(t){return I.get(t.x,t.y)}function p(t){return I.weak(t.x,t.y)}function bt(t){return new ca(t.elasticity,t.dynamicFriction,t.staticFriction,t.density,t.rollingFriction)}function Mt(t){let a=new ha;return a.collisionGroup=t.collisionGroup,a.collisionMask=t.collisionMask,a.sensorGroup=t.sensorGroup,a.sensorMask=t.sensorMask,a.fluidGroup=t.fluidGroup,a.fluidMask=t.fluidMask,a}function ht(t){let a=new U(t.density,t.viscosity);return t.gravity!=null&&(a.gravity=d(t.gravity)),a}function gt(t){let a=bt(t.material),n=Mt(t.filter),e;if(t.type==="circle"){let o=d(t.localCOM);e=new ga(t.radius,o,a,n);}else if(t.type==="capsule"){let o=d(t.localCOM);e=new ja(t.width,t.height,o,a,n);}else {let o=t.localVerts.map(l=>d(l));e=new ia(o,a,n);}return e.sensorEnabled=t.sensorEnabled,e.fluidEnabled=t.fluidEnabled,t.fluidEnabled&&t.fluidProperties!=null&&(e.fluidProperties=ht(t.fluidProperties)),e}function Ct(t){let a=t.type==="STATIC"?aa.STATIC:t.type==="KINEMATIC"?aa.KINEMATIC:aa.DYNAMIC,n=new $(a,p(t.position));n.rotation=t.rotation,t.type!=="STATIC"&&(n.velocity=d(t.velocity),n.angularVel=t.angularVel),n.kinematicVel=d(t.kinematicVel),n.kinAngVel=t.kinAngVel,n.surfaceVel=d(t.surfaceVel),t.type==="DYNAMIC"&&(n.force=d(t.force),n.torque=t.torque),t.massMode==="FIXED"&&t.mass!=null?n.mass=t.mass:t.massMode==="DEFAULT"&&(n.massMode=fa.DEFAULT),t.inertiaMode==="FIXED"&&t.inertia!=null?n.inertia=t.inertia:t.inertiaMode==="DEFAULT"&&(n.inertiaMode=ea.DEFAULT),t.gravMassMode==="SCALED"?(n.gravMassMode=da.SCALED,n.gravMassScale=t.gravMassScale):t.gravMassMode==="FIXED"&&(n.gravMassMode=da.FIXED),n.allowMovement=t.allowMovement,n.allowRotation=t.allowRotation,n.isBullet=t.bullet;for(let e of t.shapes)gt(e).body=n;return t.userData!=null&&Object.assign(n.userData,t.userData),n}function g(t,a){t.active=a.active,t.ignore=a.ignore,t.stiff=a.stiff,t.frequency=a.frequency,t.damping=a.damping,t.maxForce=a.maxForce,t.maxError=a.maxError,t.breakUnderForce=a.breakUnderForce,t.breakUnderError=a.breakUnderError,t.removeOnBreak=a.removeOnBreak,a.userData!=null&&Object.assign(t.userData,a.userData);}function St(t,a){let n=t.body1Id!=null?a[t.body1Id]??null:null,e=t.body2Id!=null?a[t.body2Id]??null:null;switch(t.type){case "PivotJoint":{let o=new qa(n,e,p(t.anchor1),p(t.anchor2));return g(o,t),o}case "DistanceJoint":{let o=new na(n,e,p(t.anchor1),p(t.anchor2),t.jointMin,t.jointMax);return g(o,t),o}case "AngleJoint":{let o=new ma(n,e,t.jointMin,t.jointMax,t.ratio);return g(o,t),o}case "MotorJoint":{let o=new pa(n,e,t.rate,t.ratio);return g(o,t),o}case "LineJoint":{let o=new oa(n,e,p(t.anchor1),p(t.anchor2),p(t.direction),t.jointMin,t.jointMax);return g(o,t),o}case "PulleyJoint":{let o=new ra(n,e,null,null,p(t.anchor1),p(t.anchor2),p(t.anchor3),p(t.anchor4),t.jointMin,t.jointMax,t.ratio);return g(o,t),o}case "WeldJoint":{let o=new sa(n,e,p(t.anchor1),p(t.anchor2),t.phase);return g(o,t),o}}}function Et(t){if(t.version!==1)throw new Error(`nape-js serialization: unsupported snapshot version ${t.version} (expected ${1})`);let a=t.broadphase==="SWEEP_AND_PRUNE"?ka.SWEEP_AND_PRUNE:ka.DYNAMIC_AABB_TREE,n=new Y(p(t.gravity),a);n.worldLinearDrag=t.worldLinearDrag,n.worldAngularDrag=t.worldAngularDrag,n.sortContacts=t.sortContacts,n.deterministic=t.deterministic??false;let e=t.bodies.map(Ct),o=t.constraints.map(r=>St(r,e)),l=new Set,c=new Set;for(let r of t.compounds){let m=new ba;for(let u of r.bodyIds)e[u].compound=m,l.add(u);for(let u of r.constraintIndices)o[u].compound=m,c.add(u);m.space=n;}for(let r=0;r<e.length;r++)l.has(r)||(e[r].space=n);for(let r=0;r<o.length;r++)c.has(r)||(o[r].space=n);return n}export{J as SNAPSHOT_VERSION,Et as spaceFromJSON,dt as spaceToJSON};//# sourceMappingURL=index.js.map
1
+ export{a as BINARY_SNAPSHOT_VERSION,c as spaceFromBinary,b as spaceToBinary}from'../chunk-N7HIFDFT.js';import {ka,Y,ba,I,aa,$,fa,ea,da,ta,sa,pa,qa,na,oa,ra,ga,ja,ia,ca,ha,U}from'../chunk-BARGM4ZO.js';var J=1;function s(t){return {x:t.x,y:t.y}}function Q(t){if(t==null)return null;try{let a=JSON.stringify(t);return a==="{}"?null:JSON.parse(a)}catch{return null}}function it(t){return {elasticity:t.elasticity,dynamicFriction:t.dynamicFriction,staticFriction:t.staticFriction,density:t.density,rollingFriction:t.rollingFriction}}function st(t){return {collisionGroup:t.collisionGroup,collisionMask:t.collisionMask,sensorGroup:t.sensorGroup,sensorMask:t.sensorMask,fluidGroup:t.fluidGroup,fluidMask:t.fluidMask}}function lt(t){if(t==null)return null;let a=t.gravity;return {density:t.density,viscosity:t.viscosity,gravity:a!=null?s(a):null}}function ct(t){let a=it(t.material),n=st(t.filter),e=t.fluidEnabled,o=e?lt(t.fluidProperties):null,l=t.sensorEnabled;if(t.isCircle()){let c=t,r=t.localCOM;return {type:"circle",radius:c.radius,localCOM:s(r),material:a,filter:n,sensorEnabled:l,fluidEnabled:e,fluidProperties:o}}else if(t.isCapsule()){let c=t,r=t.localCOM;return {type:"capsule",width:c.width,height:c.height,localCOM:s(r),material:a,filter:n,sensorEnabled:l,fluidEnabled:e,fluidProperties:o}}else {let r=t.localVerts,m=[],u=r.length;for(let b=0;b<u;b++)m.push(s(r.at(b)));return {type:"polygon",localVerts:m,material:a,filter:n,sensorEnabled:l,fluidEnabled:e,fluidProperties:o}}}var ut={1:"STATIC",2:"DYNAMIC",3:"KINEMATIC"},pt={0:"DEFAULT",1:"FIXED",2:"FIXED_GROUP"},mt={0:"DEFAULT",1:"FIXED",2:"FIXED_GROUP"},Dt={0:"DEFAULT",1:"FIXED",2:"SCALED"};function yt(t,a){let n=t.zpp_inner,e=pt[n.massMode]??"DEFAULT",o=mt[n.inertiaMode]??"DEFAULT",l=Dt[n.gravMassMode]??"DEFAULT",c=[],r=t.shapes,m=r.length;for(let u=0;u<m;u++)c.push(ct(r.at(u)));return {id:a,type:ut[n.type]??"DYNAMIC",position:s(t.position),rotation:t.rotation,velocity:s(t.velocity),angularVel:t.angularVel,kinematicVel:s(t.kinematicVel),kinAngVel:t.kinAngVel,surfaceVel:s(t.surfaceVel),force:s(t.force),torque:n.type===2?t.torque:0,massMode:e,mass:e==="FIXED"?n.cmass:null,inertiaMode:o,inertia:o==="FIXED"?n.cinertia:null,gravMassMode:l,gravMassScale:n.gravMassScale,allowMovement:t.allowMovement,allowRotation:t.allowRotation,bullet:t.isBullet,shapes:c,userData:Q(n.userData)}}function h(t,a,n,e){let o=t.zpp_inner,l=n!=null?a.get(n.zpp_inner.id)??null:null,c=e!=null?a.get(e.zpp_inner.id)??null:null;return {body1Id:l,body2Id:c,active:o.active,ignore:o.ignore,stiff:o.stiff,frequency:o.frequency,damping:o.damping,maxForce:o.maxForce,maxError:o.maxError,breakUnderForce:o.breakUnderForce,breakUnderError:o.breakUnderError,removeOnBreak:o.removeOnBreak,userData:Q(o.userData)}}function ft(t,a){switch(t.constructor?.name??""){case "PivotJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"PivotJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2)}}case "DistanceJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"DistanceJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),jointMin:e.jointMin,jointMax:e.jointMax}}case "AngleJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"AngleJoint",jointMin:e.jointMin,jointMax:e.jointMax,ratio:e.ratio}}case "MotorJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"MotorJoint",rate:e.rate,ratio:e.ratio}}case "LineJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"LineJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),direction:s(e.direction),jointMin:e.jointMin,jointMax:e.jointMax}}case "PulleyJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"PulleyJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),anchor3:s(e.anchor3),anchor4:s(e.anchor4),jointMin:e.jointMin,jointMax:e.jointMax,ratio:e.ratio}}case "WeldJoint":{let e=t;return {...h(t,a,e.body1,e.body2),type:"WeldJoint",anchor1:s(e.anchor1),anchor2:s(e.anchor2),phase:e.phase}}default:return null}}function dt(t){let a=[],n=new Map,e=new Map;function o(i){let y=i.zpp_inner.id;if(e.has(y))return;let D=a.length;n.set(i,D),e.set(y,D),a.push(yt(i,D));}let l=t.bodies,c=l.length;for(let i=0;i<c;i++)o(l.at(i));let r=t.compounds,m=r.length;for(let i=0;i<m;i++){let D=r.at(i).bodies,C=D.length;for(let f=0;f<C;f++)o(D.at(f));}let u=[],b=new Map;function I(i){if(b.has(i))return;let y=ft(i,e);y!=null&&(b.set(i,u.length),u.push(y));}let x=t.constraints,Z=x.length;for(let i=0;i<Z;i++)I(x.at(i));for(let i=0;i<m;i++){let D=r.at(i).constraints,C=D.length;for(let f=0;f<C;f++)I(D.at(f));}let V=[];for(let i=0;i<m;i++){let y=r.at(i),D=[],C=y.bodies,f=C.length;for(let M=0;M<f;M++){let F=C.at(M),S=n.get(F);S!=null&&D.push(S);}let B=[],w=y.constraints,nt=w.length;for(let M=0;M<nt;M++){let F=w.at(M),S=b.get(F);S!=null&&B.push(S);}V.push({bodyIds:D,constraintIndices:B,childIndices:[]});}let tt=t.zpp_inner.bphase.is_sweep?"SWEEP_AND_PRUNE":"DYNAMIC_AABB_TREE",et=t.gravity;return {version:1,gravity:s(et),worldLinearDrag:t.worldLinearDrag,worldAngularDrag:t.worldAngularDrag,sortContacts:t.sortContacts,deterministic:t.deterministic,broadphase:tt,bodies:a,constraints:u,compounds:V}}function d(t){return I.get(t.x,t.y)}function p(t){return I.weak(t.x,t.y)}function bt(t){return new ca(t.elasticity,t.dynamicFriction,t.staticFriction,t.density,t.rollingFriction)}function Mt(t){let a=new ha;return a.collisionGroup=t.collisionGroup,a.collisionMask=t.collisionMask,a.sensorGroup=t.sensorGroup,a.sensorMask=t.sensorMask,a.fluidGroup=t.fluidGroup,a.fluidMask=t.fluidMask,a}function ht(t){let a=new U(t.density,t.viscosity);return t.gravity!=null&&(a.gravity=d(t.gravity)),a}function gt(t){let a=bt(t.material),n=Mt(t.filter),e;if(t.type==="circle"){let o=d(t.localCOM);e=new ga(t.radius,o,a,n);}else if(t.type==="capsule"){let o=d(t.localCOM);e=new ja(t.width,t.height,o,a,n);}else {let o=t.localVerts.map(l=>d(l));e=new ia(o,a,n);}return e.sensorEnabled=t.sensorEnabled,e.fluidEnabled=t.fluidEnabled,t.fluidEnabled&&t.fluidProperties!=null&&(e.fluidProperties=ht(t.fluidProperties)),e}function Ct(t){let a=t.type==="STATIC"?aa.STATIC:t.type==="KINEMATIC"?aa.KINEMATIC:aa.DYNAMIC,n=new $(a,p(t.position));n.rotation=t.rotation,t.type!=="STATIC"&&(n.velocity=d(t.velocity),n.angularVel=t.angularVel),n.kinematicVel=d(t.kinematicVel),n.kinAngVel=t.kinAngVel,n.surfaceVel=d(t.surfaceVel),t.type==="DYNAMIC"&&(n.force=d(t.force),n.torque=t.torque),t.massMode==="FIXED"&&t.mass!=null?n.mass=t.mass:t.massMode==="DEFAULT"&&(n.massMode=fa.DEFAULT),t.inertiaMode==="FIXED"&&t.inertia!=null?n.inertia=t.inertia:t.inertiaMode==="DEFAULT"&&(n.inertiaMode=ea.DEFAULT),t.gravMassMode==="SCALED"?(n.gravMassMode=da.SCALED,n.gravMassScale=t.gravMassScale):t.gravMassMode==="FIXED"&&(n.gravMassMode=da.FIXED),n.allowMovement=t.allowMovement,n.allowRotation=t.allowRotation,n.isBullet=t.bullet;for(let e of t.shapes)gt(e).body=n;return t.userData!=null&&Object.assign(n.userData,t.userData),n}function g(t,a){t.active=a.active,t.ignore=a.ignore,t.stiff=a.stiff,t.frequency=a.frequency,t.damping=a.damping,t.maxForce=a.maxForce,t.maxError=a.maxError,t.breakUnderForce=a.breakUnderForce,t.breakUnderError=a.breakUnderError,t.removeOnBreak=a.removeOnBreak,a.userData!=null&&Object.assign(t.userData,a.userData);}function St(t,a){let n=t.body1Id!=null?a[t.body1Id]??null:null,e=t.body2Id!=null?a[t.body2Id]??null:null;switch(t.type){case "PivotJoint":{let o=new ra(n,e,p(t.anchor1),p(t.anchor2));return g(o,t),o}case "DistanceJoint":{let o=new oa(n,e,p(t.anchor1),p(t.anchor2),t.jointMin,t.jointMax);return g(o,t),o}case "AngleJoint":{let o=new na(n,e,t.jointMin,t.jointMax,t.ratio);return g(o,t),o}case "MotorJoint":{let o=new qa(n,e,t.rate,t.ratio);return g(o,t),o}case "LineJoint":{let o=new pa(n,e,p(t.anchor1),p(t.anchor2),p(t.direction),t.jointMin,t.jointMax);return g(o,t),o}case "PulleyJoint":{let o=new sa(n,e,null,null,p(t.anchor1),p(t.anchor2),p(t.anchor3),p(t.anchor4),t.jointMin,t.jointMax,t.ratio);return g(o,t),o}case "WeldJoint":{let o=new ta(n,e,p(t.anchor1),p(t.anchor2),t.phase);return g(o,t),o}}}function Et(t){if(t.version!==1)throw new Error(`nape-js serialization: unsupported snapshot version ${t.version} (expected ${1})`);let a=t.broadphase==="SWEEP_AND_PRUNE"?ka.SWEEP_AND_PRUNE:ka.DYNAMIC_AABB_TREE,n=new Y(p(t.gravity),a);n.worldLinearDrag=t.worldLinearDrag,n.worldAngularDrag=t.worldAngularDrag,n.sortContacts=t.sortContacts,n.deterministic=t.deterministic??false;let e=t.bodies.map(Ct),o=t.constraints.map(r=>St(r,e)),l=new Set,c=new Set;for(let r of t.compounds){let m=new ba;for(let u of r.bodyIds)e[u].compound=m,l.add(u);for(let u of r.constraintIndices)o[u].compound=m,c.add(u);m.space=n;}for(let r=0;r<e.length;r++)l.has(r)||(e[r].space=n);for(let r=0;r<o.length;r++)c.has(r)||(o[r].space=n);return n}export{J as SNAPSHOT_VERSION,Et as spaceFromJSON,dt as spaceToJSON};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newkrok/nape-js",
3
- "version": "3.38.0",
3
+ "version": "3.38.1",
4
4
  "description": "High-performance 2D physics engine for TypeScript & JavaScript — rigid bodies, constraints, fluid simulation, raycasting, and deterministic multiplayer. Tree-shakeable, zero dependencies.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -92,6 +92,7 @@
92
92
  "build": "tsup",
93
93
  "test": "vitest run",
94
94
  "test:watch": "vitest",
95
+ "coverage": "vitest run --coverage",
95
96
  "lint": "eslint src/ tests/",
96
97
  "format": "prettier --write src/ tests/",
97
98
  "format:check": "prettier --check src/ tests/",