|
14 | 14 |
|
15 | 15 | return new GLTFMaterialsUnlitExtension( writer ); |
16 | 16 |
|
17 | | - } ); |
18 | | - this.register( function ( writer ) { |
19 | | - |
20 | | - return new GLTFMaterialsPBRSpecularGlossiness( writer ); |
21 | | - |
22 | 17 | } ); |
23 | 18 | this.register( function ( writer ) { |
24 | 19 |
|
|
2011 | 2006 |
|
2012 | 2007 | } |
2013 | 2008 |
|
2014 | | - /** |
2015 | | - * Specular-Glossiness Extension |
2016 | | - * |
2017 | | - * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness |
2018 | | - */ |
2019 | | - class GLTFMaterialsPBRSpecularGlossiness { |
2020 | | - |
2021 | | - constructor( writer ) { |
2022 | | - |
2023 | | - this.writer = writer; |
2024 | | - this.name = 'KHR_materials_pbrSpecularGlossiness'; |
2025 | | - |
2026 | | - } |
2027 | | - writeMaterial( material, materialDef ) { |
2028 | | - |
2029 | | - if ( ! material.isGLTFSpecularGlossinessMaterial ) return; |
2030 | | - const writer = this.writer; |
2031 | | - const extensionsUsed = writer.extensionsUsed; |
2032 | | - const extensionDef = {}; |
2033 | | - if ( materialDef.pbrMetallicRoughness.baseColorFactor ) { |
2034 | | - |
2035 | | - extensionDef.diffuseFactor = materialDef.pbrMetallicRoughness.baseColorFactor; |
2036 | | - |
2037 | | - } |
2038 | | - |
2039 | | - const specularFactor = [ 1, 1, 1 ]; |
2040 | | - material.specular.toArray( specularFactor, 0 ); |
2041 | | - extensionDef.specularFactor = specularFactor; |
2042 | | - extensionDef.glossinessFactor = material.glossiness; |
2043 | | - if ( materialDef.pbrMetallicRoughness.baseColorTexture ) { |
2044 | | - |
2045 | | - extensionDef.diffuseTexture = materialDef.pbrMetallicRoughness.baseColorTexture; |
2046 | | - |
2047 | | - } |
2048 | | - |
2049 | | - if ( material.specularMap ) { |
2050 | | - |
2051 | | - const specularMapDef = { |
2052 | | - index: writer.processTexture( material.specularMap ) |
2053 | | - }; |
2054 | | - writer.applyTextureTransform( specularMapDef, material.specularMap ); |
2055 | | - extensionDef.specularGlossinessTexture = specularMapDef; |
2056 | | - |
2057 | | - } |
2058 | | - |
2059 | | - materialDef.extensions = materialDef.extensions || {}; |
2060 | | - materialDef.extensions[ this.name ] = extensionDef; |
2061 | | - extensionsUsed[ this.name ] = true; |
2062 | | - |
2063 | | - } |
2064 | | - |
2065 | | - } |
2066 | | - |
2067 | 2009 | /** |
2068 | 2010 | * Clearcoat Materials Extension |
2069 | 2011 | * |
|
0 commit comments