UNPKG

ecspresso

Version:

A minimal Entity-Component-System library for typescript and javascript.

5 lines (3 loc) 1.51 kB
var I=((b)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(b,{get:(k,B)=>(typeof require<"u"?require:k)[B]}):b)(function(b){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+b+'" is not supported')});import{definePlugin as E}from"ecspresso";function H(b,k){return b+k}function L(b){let{depthFn:k=H,systemGroup:B="isometric"}=b??{};return E("isometric-depth-sort").withComponentTypes().requires().withGroups().install((C)=>{C.addSystem("isometric-depth-sort-init").inGroup(B).setOnInitialize((x)=>{let v=x.getResource("rootContainer");v.sortableChildren=!0}),C.addSystem("isometric-depth-sort").setPriority(350).inPhase("render").inGroup(B).addQuery("sprites",{with:["sprite","worldTransform"],changed:["worldTransform"],optional:["depthOffset"]}).addQuery("graphics",{with:["graphics","worldTransform"],changed:["worldTransform"],optional:["depthOffset"]}).addQuery("containers",{with:["container","worldTransform"],changed:["worldTransform"],optional:["depthOffset"]}).setProcess(({queries:x})=>{for(let v of x.sprites){let{sprite:z,worldTransform:j,depthOffset:A}=v.components;z.zIndex=k(j.x,j.y)+(A??0)}for(let v of x.graphics){let{graphics:z,worldTransform:j,depthOffset:A}=v.components;z.zIndex=k(j.x,j.y)+(A??0)}for(let v of x.containers){let{container:z,worldTransform:j,depthOffset:A}=v.components;z.zIndex=k(j.x,j.y)+(A??0)}})})}export{L as createIsoDepthSortPlugin}; //# debugId=E8C9DCC3EA4239A864756E2164756E21 //# sourceMappingURL=depth-sort.js.map