From ca6968209eada71714591122a3ee64d74a482c71 Mon Sep 17 00:00:00 2001 From: 06wj <06wj@163.com> Date: Wed, 23 Mar 2022 15:53:40 +0800 Subject: [PATCH] feat: imporve parsing of glTF KHR_techniques_webgl extension --- src/loader/GLTFExtensions.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/loader/GLTFExtensions.js b/src/loader/GLTFExtensions.js index c6c8f189..8ea8443a 100644 --- a/src/loader/GLTFExtensions.js +++ b/src/loader/GLTFExtensions.js @@ -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'; @@ -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; } @@ -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; } };