import { ExtensionProperty , IProperty , Nullable , PropertyType , Texture , TextureChannel , TextureInfo , } from '@gltf-transform/core' ; import { KHR_MATERIALS_CLEARCOAT } from '../constants' ; interface IClearcoat extends IProperty { clearcoatFactor : number ; clearcoatTexture : Texture ; clearcoatTextureInfo : TextureInfo ; clearcoatRoughnessFactor : number ; clearcoatRoughnessTexture : Texture ; clearcoatRoughnessTextureInfo : TextureInfo ; clearcoatNormalScale : number ; clearcoatNormalTexture : Texture ; clearcoatNormalTextureInfo : TextureInfo ; } const { R , G , B } = TextureChannel ; /**
 * # Clearcoat
 *
 * Defines clear coat for a PBR material. See  MaterialsClearcoat .
  export class Clearcoat extends ExtensionProperty < IClearcoat > { public static EXTENSION_NAME = KHR_MATERIALS_CLEARCOAT ; public declare extensionName : typeof KHR_MATERIALS_CLEARCOAT ; public declare propertyType : 'Clearcoat' ; public declare parentTypes : [ PropertyType . MATERIAL ] ; protected init ( ) { this . extensionName = KHR_MATERIALS_CLEARCOAT ; this . propertyType = 'Clearcoat' ; this . parentTypes = [ PropertyType . MATERIAL ] ; } protected getDefaults ( ) { return Object . assign ( super . getDefaults ( ) as IProperty , { clearcoatFactor : 0 , clearcoatTexture : null , clearcoatTextureInfo : new TextureInfo ( this . graph , 'clearcoatTextureInfo' ) , clearcoatRoughnessFactor : 0 , clearcoatRoughnessTexture : null , clearcoatRoughnessTextureInfo : new TextureInfo ( this . graph , 'clearcoatRoughnessTextureInfo' ) , clearcoatNormalScale : 1 , clearcoatNormalTexture : null , clearcoatNormalTextureInfo : new TextureInfo ( this . graph , 'clearcoatNormalTextureInfo' ) , } ) ; } /**********************************************************************************************
     * Clearcoat.
     */ /** Clearcoat; linear multiplier. See  getClearcoatTexture .  public getClearcoatFactor ( ) { return this . get ( 'clearcoatFactor' ) ; } /** Clearcoat; linear multiplier. See  getClearcoatTexture .  public setClearcoatFactor ( factor ) { return this . set ( 'clearcoatFactor' , factor ) ; } /**
     * Clearcoat texture; linear multiplier. The `r` channel of this texture specifies an amount
     * [0-1] of coating over the surface of the material, which may have its own roughness and
     * normal map properties.
     */ public getClearcoatTexture ( ) { return this . getRef ( 'clearcoatTexture' ) ; } /**
     * Settings affecting the material's use of its clearcoat texture. If no texture is attached,
     *  TextureInfo is `null`.
      public getClearcoatTextureInfo ( ) { return this . getRef ( 'clearcoatTexture' ) ? this . getRef ( 'clearcoatTextureInfo' ) : null ; } /** Sets clearcoat texture. See  getClearcoatTexture .  public setClearcoatTexture ( texture ) { return this . setRef ( 'clearcoatTexture' , texture , { channels : R } ) ; } /**********************************************************************************************
     * Clearcoat roughness.
     */ /** Clearcoat roughness; linear multiplier. See  getClearcoatRoughnessTexture .  public getClearcoatRoughnessFactor ( ) { return this . get ( 'clearcoatRoughnessFactor' ) ; } /** Clearcoat roughness; linear multiplier. See  getClearcoatRoughnessTexture .  public setClearcoatRoughnessFactor ( factor ) { return this . set ( 'clearcoatRoughnessFactor' , factor ) ; } /**
     * Clearcoat roughness texture; linear multiplier. The `g` channel of this texture specifies
     * roughness, independent of the base layer's roughness.
     */ public getClearcoatRoughnessTexture ( ) { return this . getRef ( 'clearcoatRoughnessTexture' ) ; } /**
     * Settings affecting the material's use of its clearcoat roughness texture. If no texture is
     * attached,  TextureInfo is `null`.
      public getClearcoatRoughnessTextureInfo ( ) { return this . getRef ( 'clearcoatRoughnessTexture' ) ? this . getRef ( 'clearcoatRoughnessTextureInfo' ) : null ; } /** Sets clearcoat roughness texture. See  getClearcoatRoughnessTexture .  public setClearcoatRoughnessTexture ( texture ) { return this . setRef ( 'clearcoatRoughnessTexture' , texture , { channels : G } ) ; } /**********************************************************************************************
     * Clearcoat normals.
     */ /** Clearcoat normal scale. See  getClearcoatNormalTexture .  public getClearcoatNormalScale ( ) { return this . get ( 'clearcoatNormalScale' ) ; } /** Clearcoat normal scale. See  getClearcoatNormalTexture .  public setClearcoatNormalScale ( scale ) { return this . set ( 'clearcoatNormalScale' , scale ) ; } /**
     * Clearcoat normal map. Independent of the material base layer normal map.
     */ public getClearcoatNormalTexture ( ) { return this . getRef ( 'clearcoatNormalTexture' ) ; } /**
     * Settings affecting the material's use of its clearcoat normal texture. If no texture is
     * attached,  TextureInfo is `null`.
      public getClearcoatNormalTextureInfo ( ) { return this . getRef ( 'clearcoatNormalTexture' ) ? this . getRef ( 'clearcoatNormalTextureInfo' ) : null ; } /** Sets clearcoat normal texture. See  getClearcoatNormalTexture .  public setClearcoatNormalTexture ( texture ) { return this . setRef ( 'clearcoatNormalTexture' , texture , { channels : R | G | B } ) ; } }