@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.59 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import e from"../../request.js";import r from"../../core/Error.js";import{LRUCache as o}from"../../core/LRUCache.js";import{create as i}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{size as t,create as s}from"../../geometry/support/aaBoundingBox.js";import{objectSymbolLayerPrimitiveBoundingBox as n}from"./symbolLayerUtils3D.js";let c=a();function a(){return new o(50)}function u(){c=a()}async function l(e,o){if(e.resource?.href)return m(e.resource.href).then((e=>[e.width,e.height]));if(e.resource?.primitive)return null!=o?[o,o]:[256,256];throw new r("symbol3d:invalid-symbol-layer","symbol layers of type Icon must have either an href or a primitive resource")}function m(r){return e(r,{responseType:"image"}).then((e=>e.data))}async function f(e,o=null){if(!e.isPrimitive){const o=e.resource?.href;if(!o)throw new r("symbol:invalid-resource","The symbol does not have a valid resource");const s=c.get(o);if(void 0!==s)return s;const{fetch:n}=await import("../../views/3d/layers/graphics/objectResourceUtils.js"),a=await n(o,{disableTextures:!0,spherical:!0}),u=t(a.referenceBoundingBox,i());return c.put(o,u),u}if(!e.resource?.primitive)throw new r("symbol:invalid-resource","The symbol does not have a valid resource");const a=s(n(e.resource.primitive));if(null!=o)for(let r=0;r<a.length;r++)a[r]*=o;return t(a,i())}export{u as clearBoundingBoxCache,l as computeIconLayerResourceSize,f as computeObjectLayerResourceSize};