import { ColorUtils , ExtensionProperty , IProperty , Nullable , PropertyType , Texture , TextureChannel , TextureInfo , vec3 , } from '@gltf-transform/core' ; import { KHR_MATERIALS_SHEEN } from '../constants' ; interface ISheen extends IProperty { sheenColorFactor : vec3 ; sheenColorTexture : Texture ; sheenColorTextureInfo : TextureInfo ; sheenRoughnessFactor : number ; sheenRoughnessTexture : Texture ; sheenRoughnessTextureInfo : TextureInfo ; } const { R , G , B , A } = TextureChannel ; /**
 * # Sheen
 *
 * Defines sheen on a PBR  Material . See  MaterialsSheen .
  export class Sheen extends ExtensionProperty < ISheen > { public static EXTENSION_NAME = KHR_MATERIALS_SHEEN ; public declare extensionName : typeof KHR_MATERIALS_SHEEN ; public declare propertyType : 'Sheen' ; public declare parentTypes : [ PropertyType . MATERIAL ] ; protected init ( ) { this . extensionName = KHR_MATERIALS_SHEEN ; this . propertyType = 'Sheen' ; this . parentTypes = [ PropertyType . MATERIAL ] ; } protected getDefaults ( ) { return Object . assign ( super . getDefaults ( ) as IProperty , { sheenColorFactor : [ 0.0 , 0.0 , 0.0 ] as vec3 , sheenColorTexture : null , sheenColorTextureInfo : new TextureInfo ( this . graph , 'sheenColorTextureInfo' ) , sheenRoughnessFactor : 0.0 , sheenRoughnessTexture : null , sheenRoughnessTextureInfo : new TextureInfo ( this . graph , 'sheenRoughnessTextureInfo' ) , } ) ; } /**********************************************************************************************
     * Sheen color.
     */ /** Sheen; linear multiplier. */ public getSheenColorFactor ( ) { return this . get ( 'sheenColorFactor' ) ; } /** Sheen; hex color in sRGB colorspace. */ public getSheenColorHex ( ) { return ColorUtils . factorToHex ( this . getSheenColorFactor ( ) ) ; } /** Sheen; linear multiplier. */ public setSheenColorFactor ( factor ) { return this . set ( 'sheenColorFactor' , factor ) ; } /** Sheen; hex color in sRGB colorspace. */ public setSheenColorHex ( hex ) { const factor = this . getSheenColorFactor ( ) . slice ( ) as vec3 ; return this . set ( 'sheenColorFactor' , ColorUtils . hexToFactor ( hex , factor ) ) ; } /**
     * Sheen color texture, in sRGB colorspace.
     */ public getSheenColorTexture ( ) { return this . getRef ( 'sheenColorTexture' ) ; } /**
     * Settings affecting the material's use of its sheen color texture. If no texture is attached,
     *  TextureInfo is `null`.
      public getSheenColorTextureInfo ( ) { return this . getRef ( 'sheenColorTexture' ) ? this . getRef ( 'sheenColorTextureInfo' ) : null ; } /** Sets sheen color texture. See  getSheenColorTexture .  public setSheenColorTexture ( texture ) { return this . setRef ( 'sheenColorTexture' , texture , { channels : R | G | B } ) ; } /**********************************************************************************************
     * Sheen roughness.
     */ /** Sheen roughness; linear multiplier. See  getSheenRoughnessTexture .  public getSheenRoughnessFactor ( ) { return this . get ( 'sheenRoughnessFactor' ) ; } /** Sheen roughness; linear multiplier. See  getSheenRoughnessTexture .  public setSheenRoughnessFactor ( factor ) { return this . set ( 'sheenRoughnessFactor' , factor ) ; } /**
     * Sheen roughness texture; linear multiplier. The `a` channel of this texture specifies
     * roughness, independent of the base layer's roughness.
     */ public getSheenRoughnessTexture ( ) { return this . getRef ( 'sheenRoughnessTexture' ) ; } /**
     * Settings affecting the material's use of its sheen roughness texture. If no texture is
     * attached,  TextureInfo is `null`.
      public getSheenRoughnessTextureInfo ( ) { return this . getRef ( 'sheenRoughnessTexture' ) ? this . getRef ( 'sheenRoughnessTextureInfo' ) : null ; } /**
     * Sets sheen roughness texture.  The `a` channel of this texture specifies
     * roughness, independent of the base layer's roughness.
     */ public setSheenRoughnessTexture ( texture ) { return this . setRef ( 'sheenRoughnessTexture' , texture , { channels : A } ) ; } }