From a6d735c8acd6fb42af12eb1b799ea6b186697cff Mon Sep 17 00:00:00 2001 From: Night_Gryphon Date: Sat, 15 Jul 2023 11:10:49 +0000 Subject: [PATCH] FIX THREE r154 shaders glslVersion (sdf/msdf shaders; text component) --- src/core/shader.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/shader.js b/src/core/shader.js index a7aff412a32..f26fd2f1c23 100755 --- a/src/core/shader.js +++ b/src/core/shader.js @@ -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 });