/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{perVertexElevationAligner as e}from"../graphics/ElevationAligners.js";import{writeMapSpaceUVCoordsPerConnectedPart as r,writeMapSpaceUVCoords as a}from"./uvUtils.js";import{ColorMaterial as n}from"../../webgl-engine/materials/ColorMaterial.js";import{PatternMaterial as i}from"../../webgl-engine/materials/PatternMaterial.js";function o(e,r){r.useIndexing=!0;const a=e?.pattern;return null==a||"solid"===a.style?new n(r):"none"===a.style?(r.color=t(0,0,0,0),r.forceTransparentMode=!0,new n(r)):(r.style=s(a.style),new i(r))}function s(t){switch(t){case"horizontal":return 0;case"vertical":return 1;case"cross":return 2;case"forward-diagonal":return 3;case"backward-diagonal":return 4;case"diagonal-cross":return 5;default:return}}function l(t){return t.material instanceof i&&!t.material.parameters.draped}function c(t,e){if(l(t)){const n=t.attributes.get("position").data,i=t.getMutableAttribute("uvMapSpace").data,o=t.getMutableAttribute("boundingRect"),s=t.getMutableAttribute("textureElementIndex");if(null!=s&&null!=t.drawIndices)return void r(i,o.data,s.data,n,t.drawIndices,e);a(i,o.data,n,e)}}function u(t,r,a,n,i){const o=e(t,r,a,n,i),s=t.stageObject.geometries;for(const e of s)c(e,i);return o}export{o as createMaterial,s as parsePatternStyle,l as requiresUVUpdates,c as updateMapSpaceUVCoords,u as uvElevationAligner};
