Skip to content

Commit

Permalink
feat: imporve parsing of glTF KHR_techniques_webgl extension
Browse files Browse the repository at this point in the history
  • Loading branch information
06wj committed Mar 23, 2022
1 parent 4a9a43d commit ca69682
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/loader/GLTFExtensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import SpotLight from '../light/SpotLight';
import Color from '../math/Color';
import math from '../math/math';
import * as util from '../utils/util';
import log from '../utils/log';
import ShaderMaterial from '../material/ShaderMaterial';
import semantic from '../material/semantic';
import constants from '../constants';
Expand Down Expand Up @@ -406,9 +405,6 @@ export const KHR_techniques_webgl = {
} else {
uniformObject = uniformDef.semantic;
}
} else {
log.warn(`KHR_techniques_webgl: no ${uniformName} value found!`);
uniformObject = semantic.blankInfo;
}
uniforms[uniformName] = uniformObject;
}
Expand All @@ -423,12 +419,28 @@ export const KHR_techniques_webgl = {
const shaderMaterial = new ShaderMaterial({
needBasicUnifroms: false,
needBasicAttributes: false,
useHeaderCache: true,
vs: vertexText,
fs: fragmentText,
attributes,
uniforms
});

if (info.premultiplyAlpha !== undefined) {
shaderMaterial.premultiplyAlpha = info.premultiplyAlpha;
}

if (info.defines) {
shaderMaterial.getCustomRenderOption = function() {
return info.defines;
};
}

if (programInfo.name !== undefined) {
shaderMaterial.shaderName = programInfo.name;
shaderMaterial.shaderCacheId = `KHR_techniques_webgl_${programInfo.name}`;
}

return shaderMaterial;
}
};

0 comments on commit ca69682

Please sign in to comment.