@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.93 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import t from"../../core/Error.js";import e from"../../core/Logger.js";import{SizedPixelFormat as r,CompressedTextureFormat as n,TextureType as i,PixelFormat as o,PixelType as a}from"./enums.js";const u=()=>e.getLogger("esri/views/webgl/textureUtils");function l(t){(null!=t.width&&t.width<0||null!=t.height&&t.height<0||null!=t.depth&&t.depth<0)&&u().error("Negative dimension parameters are not allowed!")}function h(t){return t in r}function c(t){return t in n}function d(t){return null!=t&&"type"in t&&"compressed"===t.type}function s(t){return!!t.descriptor.internalFormat&&c(t.descriptor.internalFormat)}function m(t){return null!=t&&"byteLength"in t}function f(t){return null!=t&&!d(t)&&!m(t)}function p(t){return t===i.TEXTURE_3D||t===i.TEXTURE_2D_ARRAY}function E(t,e,r,n=1){let o=Math.max(e,r);return t===i.TEXTURE_3D&&(o=Math.max(o,n)),Math.floor(Math.log2(o))+1}function T(e){if(null!=e.internalFormat)return e.internalFormat===o.DEPTH_STENCIL?o.DEPTH24_STENCIL8:e.internalFormat;switch(e.dataType){case a.FLOAT:switch(e.pixelFormat){case o.RGBA:return r.RGBA32F;case o.RGB:return r.RGB32F;default:throw new t("Unable to derive format")}case a.UNSIGNED_BYTE:switch(e.pixelFormat){case o.RGBA:return r.RGBA8;case o.RGB:return r.RGB8}}return e.internalFormat=e.pixelFormat===o.DEPTH_STENCIL?o.DEPTH24_STENCIL8:e.pixelFormat}function g(t){let e="width"in t?t.width:t.codedWidth,r="height"in t?t.height:t.codedHeight;const n=1;return t instanceof HTMLVideoElement&&(e=t.videoWidth,r=t.videoHeight),{width:e,height:r,depth:n}}export{E as calcMipmapLevels,T as deriveInternalFormat,g as getDimensions,p as is3DTarget,m as isArrayBufferView,d as isCompressedData,c as isCompressedFormat,s as isCompressedTexture,h as isSizedPixelFormat,f as isTexImageSource,l as validateTexture};