@hatiolab/things-scene 10.0.0-beta.88 → 10.0.0-beta.89

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 @@
1
+ class t{positionAt(t,e,s){return 0!==t?null:e.localPosition??{x:0,y:0,z:0}}capacity(t){return 1}}const e=new t;class s{constructor(t){this.owner=t}positionAt(t,e,s,n){if(0!==t)return null;const i=this.owner?.state?.width??0,r=this.owner?.state?.height??0,o=n?.state?.width??0,a=n?.state?.height??0;return{x:Math.max(0,(i-o)/2),y:Math.max(0,(r-a)/2),z:0}}capacity(t){return t.maxCount??1}}const n="_transferSlotId";function i(t){return class extends t{get slots(){return[]}get arrangementStrategy(){return e}canReceive(t){return null!==this.findSlot(t)}findSlot(t){const e=this.slots;if(!e.length)return null;for(const s of e){if(s.allowedTypes?.length){const e=t?.state?.type??t?.type;if(!e||!s.allowedTypes.includes(e))continue}const e=s.maxCount??this.arrangementStrategy.capacity(s);if(!(this._countOccupied(s.id)>=e))return s}return null}async receive(t,e={}){const s=this.findSlot(t);if(!s)return void this.trigger?.("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:"no-slot"});const i=this._countOccupied(s.id),r=this.arrangementStrategy.positionAt(i,s,i,t);t[n]=s.id;const{animated:o=!1,duration:a,ease:c}=e;this.reparent?.(t,{animated:o,duration:a,ease:c}),!o&&t._realObject&&(t._realObject.suppressTransform=!1);{const e=this._realObject?.receivingSurfaceY??0,n={};if(r&&(n.left=r.x,n.top=r.y),0!==e)n.zPos=0;else if(s.localPosition&&Number.isFinite(s.localPosition.z)){const t=this._realObject?.geometricOffsetY??0;n.zPos=s.localPosition.z+t}Object.keys(n).length&&t.setState?.(n)}this.trigger?.("transfer-received",{type:"transfer-received",component:t,container:this,slotId:s.id})}async dispatch(t,e,s={}){e.canReceive(t)?(delete t[n],await e.receive(t,s),this.trigger?.("transfer-dispatched",{type:"transfer-dispatched",component:t,container:this,target:e})):this.trigger?.("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:"target-full"})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e="rejected"){this.trigger?.("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:e})}attachPointFor(t){const e=t?.[n];if(!e)return null;const s=this.slots.find(t=>t.id===e);return s?{position:s.localPosition??{x:0,y:0,z:0},rotation:s.localRotation??{x:0,y:0,z:0},slotId:s.id}:null}_countOccupied(t){const e=this.components;return e?e.filter(e=>e[n]===t).length:0}}}const r=new class{constructor(){this._now=0,this._speed=1,this._paused=!1,this._listeners=new Set}get now(){return this._now}get speed(){return this._speed}set speed(t){this._speed=Math.max(0,t),this._speed>0&&(this._paused=!1)}get isPaused(){return this._paused}pause(){this._paused=!0}resume(){this._paused=!1}tick(t){if(this._paused||0===this._speed)return 0;const e=Math.min(t,200)*this._speed;return this._now+=e,this._notify(e),e}step(t){t<=0||(this._now+=t,this._notify(t))}onTick(t){return this._listeners.add(t),()=>this._listeners.delete(t)}_notify(t){this._listeners.forEach(e=>e(t))}};export{s as CenteringSlotStrategy,i as ContainerCapacity,t as FixedSlotStrategy,n as TRANSFER_SLOT_KEY,e as fixedSlotStrategy,r as globalSimClock};