nanogl-gltf
Version:
37 lines (36 loc) • 1.31 kB
JavaScript
import GltfTypes from "../../types/GltfTypes";
import Material from "./PbrSpecularGlossinessMaterial";
const EXT_ID = 'KHR_materials_pbrSpecularGlossiness';
class Instance {
constructor(gltfLoader) {
this.name = EXT_ID;
this.priority = 1;
this.loader = gltfLoader;
}
loadElement(data) {
if (data.gltftype === GltfTypes.MATERIAL && data.extensions && data.extensions[EXT_ID]) {
const material = new Material();
return material.parse(this.loader, data).then(() => material);
}
return null;
}
acceptElement(data, element) {
return null;
}
}
/**
* In PBR materials, two workflows exist for specifying the surface appearance of a material:
* - Metallic-Roughness workflow, defined natively in nanogl-gltf with PbrMetallicRoughness element,
* - Specular-Glossiness workflow, defined with this extension.
*
* This extension allows Materials to be defined using the specular-glossiness workflow, with diffuseTexture as the base color,
* and specularGlossinessTexture containing the specular and glossiness data.
*/
export default class KHR_materials_pbrSpecularGlossiness {
constructor() {
this.name = EXT_ID;
}
createInstance(gltfLoader) {
return new Instance(gltfLoader);
}
}