@@ -46,6 +46,18 @@ class GLTFExporter {
4646
4747 } ) ;
4848
49+ this . register ( function ( writer ) {
50+
51+ return new GLTFMaterialsTransmissionExtension ( writer ) ;
52+
53+ } ) ;
54+
55+ this . register ( function ( writer ) {
56+
57+ return new GLTFMaterialsVolumeExtension ( writer ) ;
58+
59+ } ) ;
60+
4961 }
5062
5163 register ( callback ) {
@@ -2215,6 +2227,93 @@ class GLTFMaterialsPBRSpecularGlossiness {
22152227
22162228}
22172229
2230+ /**
2231+ * Transmission Materials Extension
2232+ *
2233+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
2234+ */
2235+ class GLTFMaterialsTransmissionExtension {
2236+
2237+ constructor ( writer ) {
2238+
2239+ this . writer = writer ;
2240+ this . name = 'KHR_materials_transmission' ;
2241+
2242+ }
2243+
2244+ writeMaterial ( material , materialDef ) {
2245+
2246+ if ( ! material . isMeshPhysicalMaterial || material . transmission === 0 ) return ;
2247+
2248+ const writer = this . writer ;
2249+ const extensionsUsed = writer . extensionsUsed ;
2250+
2251+ const extensionDef = { } ;
2252+
2253+ extensionDef . transmissionFactor = material . transmission ;
2254+
2255+ if ( material . transmissionMap ) {
2256+
2257+ const transmissionMapDef = { index : writer . processTexture ( material . transmissionMap ) } ;
2258+ writer . applyTextureTransform ( transmissionMapDef , material . transmissionMap ) ;
2259+ extensionDef . transmissionTexture = transmissionMapDef ;
2260+
2261+ }
2262+
2263+ materialDef . extensions = materialDef . extensions || { } ;
2264+ materialDef . extensions [ this . name ] = extensionDef ;
2265+
2266+ extensionsUsed [ this . name ] = true ;
2267+
2268+ }
2269+
2270+ }
2271+
2272+ /**
2273+ * Materials Volume Extension
2274+ *
2275+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume
2276+ */
2277+ class GLTFMaterialsVolumeExtension {
2278+
2279+ constructor ( writer ) {
2280+
2281+ this . writer = writer ;
2282+ this . name = 'KHR_materials_volume' ;
2283+
2284+ }
2285+
2286+ writeMaterial ( material , materialDef ) {
2287+
2288+ if ( ! material . isMeshPhysicalMaterial || material . thickness === 0 ) return ;
2289+
2290+ const writer = this . writer ;
2291+ const extensionsUsed = writer . extensionsUsed ;
2292+
2293+ const extensionDef = { } ;
2294+
2295+ extensionDef . thicknessFactor = material . thickness ;
2296+
2297+ if ( material . thicknessMap ) {
2298+
2299+ const thicknessMapDef = { index : writer . processTexture ( material . thicknessMap ) } ;
2300+ writer . applyTextureTransform ( thicknessMapDef , material . thicknessMap ) ;
2301+ extensionDef . thicknessTexture = thicknessMapDef ;
2302+
2303+ }
2304+
2305+ extensionDef . attenuationDistance = material . attenuationDistance ;
2306+ extensionDef . attenuationColor = material . attenuationTint . toArray ( ) ;
2307+
2308+ materialDef . extensions = materialDef . extensions || { } ;
2309+ materialDef . extensions [ this . name ] = extensionDef ;
2310+
2311+ extensionsUsed [ this . name ] = true ;
2312+
2313+ }
2314+
2315+ }
2316+
22182317/**
22192318 * Static utility functions
22202319 */
0 commit comments