|
@@ -111,6 +111,12 @@ class GLTFExporter {
|
|
|
|
|
|
} );
|
|
|
|
|
|
+ this.register( function ( writer ) {
|
|
|
+
|
|
|
+ return new GLTFMaterialsDispersionExtension( writer );
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
this.register( function ( writer ) {
|
|
|
|
|
|
return new GLTFMaterialsIridescenceExtension( writer );
|
|
@@ -2648,6 +2654,40 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Materials dispersion Extension
|
|
|
+ *
|
|
|
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_dispersion
|
|
|
+ */
|
|
|
+class GLTFMaterialsDispersionExtension {
|
|
|
+
|
|
|
+ constructor( writer ) {
|
|
|
+
|
|
|
+ this.writer = writer;
|
|
|
+ this.name = 'KHR_materials_dispersion';
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ writeMaterial( material, materialDef ) {
|
|
|
+
|
|
|
+ if ( ! material.isMeshPhysicalMaterial || material.dispersion === 0 ) return;
|
|
|
+
|
|
|
+ const writer = this.writer;
|
|
|
+ const extensionsUsed = writer.extensionsUsed;
|
|
|
+
|
|
|
+ const extensionDef = {};
|
|
|
+
|
|
|
+ extensionDef.dispersion = material.dispersion;
|
|
|
+
|
|
|
+ materialDef.extensions = materialDef.extensions || {};
|
|
|
+ materialDef.extensions[ this.name ] = extensionDef;
|
|
|
+
|
|
|
+ extensionsUsed[ this.name ] = true;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Iridescence Materials Extension
|
|
|
*
|