UNPKG

@downpourdigital/physics

Version:

Animation physics!

2 lines (1 loc) 966 B
class t{constructor(){this.entities=[]}add(t){this.entities.push(t)}remove(t){this.entities.includes(t)&&this.entities.splice(this.entities.findIndex((e=>e===t)),1)}step(t){this.entities.forEach((e=>{e.step(t)}))}}const e=new t;function s(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(s[i[n]]=t[i[n]])}return s}class i{constructor({maxTimestep:t=17,maxStepCount:s=8,autoStep:i=!0}={}){this.lastFrame=0,this.isResting=!1,this.maxTimestep=t,this.maxStepCount=s,i&&e.add(this)}step(t){if(!this.isResting){let e=this.lastFrame,s=0;for(;e<t&&s<this.maxStepCount;){const i=Math.min(t-e,this.maxTimestep);this.integrate(i),e+=i,s+=1}}this.lastFrame=t}integrate(t){}stop(){e.remove(this)}}export{i as S,t as W,s as _,e as d};