/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{invert as e}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{IDENTITY as t,create as r}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{ones as s,clone as o}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{VertexPositionDrawParameters as i}from"../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import{TwoVectorPosition as a}from"../../core/util/TwoVectorPosition.js";class n extends i{constructor(s,o,i){super(),this.baseColorTextureSampler=i,this._componentParameters=h;const{transform:n,toMapSpace:m}=s;this.toMapSpace=m;const l=new a(n.position);switch(this.transformWorldFromModelTL=l.low,this.transformWorldFromModelTH=l.high,s.geometry.parameters.vertexPositionRotationType){case 0:this.transformWorldFromModelRS=t;break;case 1:this.transformWorldFromModelRS=n.rotationScale;break;case 2:this.transformWorldFromModelRS=e(r(),n.rotationScale)??t}this.useENUForGlobalOverlayUV=s.obb.radius<u,this.baseColor=o.baseColor,this.opacity=o.opacity,this.textureAlphaCutoff=o.textureAlphaCutoff,this.mrrFactors=o.mrrFactors,this.emissiveBaseColor=o.emissiveBaseColor,this.baseColorTexture=o.baseColorTexture,this.metallicRoughnessTexture=o.metallicRoughnessTexture,this.normalTexture=o.normalTexture,this.occlusionTexture=o.occlusionTexture,this.emissionTexture=o.emissionTexture;const c=new Float32Array(15);c.set(this.transformWorldFromModelTL,0),c.set(this.transformWorldFromModelTH,3),c.set(this.transformWorldFromModelRS,6),this.transformationFloats=c}destroy(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}setTransformationDrawId(e){this.transformationDrawId=e}get texture(){return this.baseColorTexture?.texture}get textureSampler(){return this.baseColorTextureSampler}get textureMetallicRoughness(){return this.metallicRoughnessTexture?.texture}get textureEmissive(){return this.emissionTexture?.texture}get textureOcclusion(){return this.occlusionTexture?.texture}get textureNormal(){return this.normalTexture?.texture}get componentParameters(){return this._componentParameters}get emissiveStrength(){const e=this._componentParameters;return 0===e.componentDataType?e.emissiveStrength:void 0}updateComponentParameters(e,t){this._componentParameters=e,this.textureBackedBuffer=t}get castAnyShadows(){return 2!==this.componentParameters.castShadows}}class m{constructor(e,t,r,s,i){this.castShadows=i,this.componentDataType=0,this.externalColor=o(e),this.externalColorMixMode=t,this.emissiveStrength=r,this.emissiveSource=s}get transparent(){return this.externalColor[3]<1?0:2}get opaqueOverride(){return 3===this.externalColorMixMode&&1===this.externalColor[3]?0:2}get emissiveOverride(){return this.emissiveStrength>0?0:2}get emissiveSourceOverride(){return 1===this.emissiveSource?0:2}}class l{constructor(e,t,r,s,o){this.transparent=e,this.opaqueOverride=t,this.emissiveOverride=r,this.emissiveSourceOverride=s,this.castShadows=o,this.componentDataType=1}}const h=new m(s(),1,0,0,0),u=5e4;export{n as ComponentDrawParametersImplementation,m as ComponentParametersUniform,l as ComponentParametersVarying,h as defaultComponentParameters};
