@animech-public/playcanvas
Version:
PlayCanvas WebGL game engine
2 lines (1 loc) • 770 B
JavaScript
import{pixelFormatInfo as t,PIXELFORMAT_PVRTC_2BPP_RGB_1 as a,PIXELFORMAT_PVRTC_2BPP_RGBA_1 as l}from"./constants.js";class e{static calcLevelDimension(t,a){return Math.max(t>>a,1)}static calcMipLevelsCount(t,a,l=1){return 1+Math.floor(Math.log2(Math.max(t,a,l)))}static calcLevelGpuSize(e,o,c,r){var n,i,s;const M=t.get(r),h=null!=(n=null==(i=t.get(r))?void 0:i.size)?n:0;if(h>0)return e*o*c*h;const u=null!=(s=M.blockSize)?s:0;let m=Math.floor((e+3)/4);const f=Math.floor((o+3)/4),x=Math.floor((c+3)/4);return r!==a&&r!==l||(m=Math.max(Math.floor(m/2),1)),m*f*x*u}static calcGpuSize(t,a,l,o,c,r){let n=0;for(;n+=e.calcLevelGpuSize(t,a,l,o),c&&(1!==t||1!==a||1!==l);)t=Math.max(t>>1,1),a=Math.max(a>>1,1),l=Math.max(l>>1,1);return n*(r?6:1)}}export{e as TextureUtils};