This bridge is no longer necessary in
firstname.lastname@example.org and above. See three-glslify-example for a full example of using ThreeJS + glslify.
A helper to turn glslify shader into a ThreeJS shader object.
var THREE =//inline our shader codevar glslify =var source =//create a shader that ThreeJS will recognizevar createShader = THREEvar myShader =//we can now use it in ShaderMaterial or EffectComposervar pass = myShadereffectComposer
myShader object looks like this, with new instances of Texture, Vector2, etc. based on the uniform type. Attributes start with empty arrays.
vertexShader: '... source ...'fragmentShader: '... source ...'uniforms:u_tex0: type: 't' value:... etcattributes:displacement: type: 'f' value:
Creates a shader with the given source (from glslify, using
sourceOnly) and options.
colorsan array of uniform names that should be mapped to THREE.Color typed,
'c'. Otherwise these will just be plain THREE.Vector3 types,
Since ThreeJS release cycles are unpredictable and don't use semantic versioning, this module may break with newer versions of ThreeJS. It currently works with three 0.68.0 (r68). Send issues or PRs if you find versioning problems.
ThreeJS distinguishes between an array of THREE.Vector3 objects, and a flattened
vec3 type represented by floats (
fv). This module only sees the
vec3 array type, and assumes they are to be represented by an array of THREE.Vector3 elements. Same with
MIT, see LICENSE.md for details.