From f0befe57fcdbf69540a53222f6987615931407e0 Mon Sep 17 00:00:00 2001 From: Christoph Diehl <1614333+posidron@users.noreply.github.com> Date: Tue, 20 Feb 2018 03:05:42 +0100 Subject: [PATCH] Add parseUniforms and parseAttributes for WebGL shaders --- lib/make/webgl.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/make/webgl.js b/lib/make/webgl.js index 9354ac6..e005723 100644 --- a/lib/make/webgl.js +++ b/lib/make/webgl.js @@ -64,5 +64,23 @@ 'ArrayBufferView' ] return random.item(sources) + }, + parseUniforms: (shader) => { + let names = [], result = shader.match(/uniform .* (\w+)(?=;)/gm) + if (result) { + result.forEach(function (v) { + names.push(v.split(" ").pop()) + }) + } + return names + }, + parseAttributes: (shader) => { + let names = [], result = shader.match(/attribute .* (\w+)(?=;)/gm) + if (result) { + result.forEach(function (v) { + names.push(v.split(" ").pop()) + }) + } + return names } }