Skip to content

Commit

Permalink
FIX THREE r154 shaders glslVersion (sdf/msdf shaders; text component)
Browse files Browse the repository at this point in the history
  • Loading branch information
nightgryphon committed Jul 15, 2023
1 parent ac117ea commit a6d735c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/core/shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,23 @@ Shader.prototype = {
init: function (data) {
this.attributes = this.initVariables(data, 'attribute');
this.uniforms = this.initVariables(data, 'uniform');

// THREE r154 require '#version' as standalone value in glslVersion
var version = undefined;
for (var name of ['vertexShader', 'fragmentShader'] ) {
var Lines = this[name].split("\n");
var pos = Lines[0].indexOf('#version');

if (pos >= 0) {
version = Lines.shift().substr(pos+9);
this[name] = Lines.join("\n");
}
}

this.material = new (this.raw ? THREE.RawShaderMaterial : THREE.ShaderMaterial)({
// attributes: this.attributes,
uniforms: this.uniforms,
glslVersion: version,
vertexShader: this.vertexShader,
fragmentShader: this.fragmentShader
});
Expand Down

0 comments on commit a6d735c

Please sign in to comment.