Skip to content

Commit 61b1485

Browse files
Add KHR_materials_transmission export support (playcanvas#8277)
* Add KHR_materials_transmission export support * Update src/extras/exporters/gltf-exporter.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 3ffeec5 commit 61b1485

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/extras/exporters/gltf-exporter.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ const textureSemantics = [
125125
'emissiveMap',
126126
'metalnessMap',
127127
'normalMap',
128+
'refractionMap',
128129
'specularityFactorMap',
129130
'specularMap'
130131
];
@@ -499,6 +500,21 @@ class GltfExporter extends CoreExporter {
499500
}
500501
}
501502

503+
// KHR_materials_transmission
504+
if (mat.useDynamicRefraction && (mat.refraction !== 0 || mat.refractionMap)) {
505+
const transmissionExt = {};
506+
507+
if (mat.refraction !== 0) {
508+
transmissionExt.transmissionFactor = mat.refraction;
509+
}
510+
511+
this.attachTexture(resources, mat, transmissionExt, 'transmissionTexture', 'refractionMap', json);
512+
513+
if (Object.keys(transmissionExt).length > 0) {
514+
this.addExtension(json, output, 'KHR_materials_transmission', transmissionExt);
515+
}
516+
}
517+
502518
// KHR_materials_unlit
503519
if (!mat.useLighting) {
504520
this.addExtension(json, output, 'KHR_materials_unlit');

0 commit comments

Comments
 (0)