Skip to content

Commit a6d735c

Browse files
committed
FIX THREE r154 shaders glslVersion (sdf/msdf shaders; text component)
1 parent ac117ea commit a6d735c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/core/shader.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,23 @@ Shader.prototype = {
5252
init: function (data) {
5353
this.attributes = this.initVariables(data, 'attribute');
5454
this.uniforms = this.initVariables(data, 'uniform');
55+
56+
// THREE r154 require '#version' as standalone value in glslVersion
57+
var version = undefined;
58+
for (var name of ['vertexShader', 'fragmentShader'] ) {
59+
var Lines = this[name].split("\n");
60+
var pos = Lines[0].indexOf('#version');
61+
62+
if (pos >= 0) {
63+
version = Lines.shift().substr(pos+9);
64+
this[name] = Lines.join("\n");
65+
}
66+
}
67+
5568
this.material = new (this.raw ? THREE.RawShaderMaterial : THREE.ShaderMaterial)({
5669
// attributes: this.attributes,
5770
uniforms: this.uniforms,
71+
glslVersion: version,
5872
vertexShader: this.vertexShader,
5973
fragmentShader: this.fragmentShader
6074
});

0 commit comments

Comments
 (0)