I’m learning three.js using this tutorial: http://demo.bkcore.com/threejs/webgl_tron_glow_seq.html.
The tutorial itself works fine, but my own code, based on it fails with errors like:
ERROR: 0:26: 'nuniform' : syntax error Three.js:325
precision highp float;
#define MAX_DIR_LIGHTS 0
...
uniform vec3 cameraPosition;
uniform sampler2D tDiffuse;nuniform sampler2D tGlow;nvarying vec2 vUv;nvoid main() {nvec4 texel = texture2D( tDiffuse, vUv );nvec4 glow = texture2D( tGlow, vUv );ngl_FragColor = texel + vec4(0.5, 0.75, 1.0, 1.0) * glow * 2.0;n}
ERROR: 0:62: 'nvoid' : syntax error Three.js:325
precision highp float;
#define VERTEX_TEXTURES
...
varying vec2 vUv;nvoid main() {nvUv = vec2( uv.x, 1.0 - uv.y );ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );n}
etc.
It looks like browser (google chrome) doesn’t parse properly strings with shaders encoded in them.
Errors appear in the code from three.js sources (minified version).
At a glance, the code is ok.
I’m just missing something, but I have no idea what exactly.
Any help?
It looks to me like there are “\n”s in there causing problems. It looks like the \ is removed but the n is left in.