I havd an object on the scene, rendering behind the scene, i dont understand why, here is the material:
const cubeMaterial = new THREE.RawShaderMaterial({
uniforms: {},
vertexShader: `
precision highp float;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
attribute vec3 position;
attribute vec3 color;
attribute vec3 offset;
attribute float a;
attribute float count;
varying vec3 vColor;
varying vec3 pos;
varying vec3 off;
varying float alpha;
varying float cnt;
void main() {
vColor = color;
pos=vec3(offset + position);
off=offset;
alpha = a;
cnt=count;
gl_Position = projectionMatrix * modelViewMatrix * vec4( pos, 1.0 );
}
`,
fragmentShader: `
precision highp float;
varying vec3 vColor;
varying vec3 pos;
varying vec3 off;
varying float alpha;
varying float cnt;
float map(float value, float inMin, float inMax, float outMin, float outMax) {
return outMin + (outMax - outMin) * (value - inMin) / (inMax - inMin);
}
void main() {
/* if(cnt > MAX_RANGE || cnt < MIN_RANGE || off.y > CLIP_HEIGHT){
discard;
} */
float dis = distance(pos,off);
float mapped = map(dis, BOX_SIZE / 2.0, BOX_DIAGONAL / 2.0, 0.35, 0.85);
float transparency = mix(.15, .75, alpha);
gl_FragColor = vec4(vColor, mapped * transparency);
}`,
defines: {
CLIP_HEIGHT: (clippingHeight || 1000).toFixed(2),
MIN_RANGE: minRange.toFixed(2),
MAX_RANGE: maxRange.toFixed(2),
BOX_SIZE: boxSize.toFixed(2),
BOX_DIAGONAL: Math.sqrt(Math.pow(boxSize, 2) + Math.pow(boxSize, 2)).toFixed(2)
},
// flatShading: true,
transparent: true,
lights: false,
opacity: 0.8,
depthWrite: false,
blending: THREE.AdditiveBlending,
fog: false
});