Hello everyone! I have a problem when displaying Points. When I move away from the camera at a certain distance, my Points disappear. What could be the problem?
const geometry = new BufferGeometry();
geometry.setAttribute('position', new BufferAttribute(new Float32Array([position.x, position.y, position.z]), 3));
let vertexShader = `
void main() {
vec4 viewPos = modelViewMatrix * vec4(position, 1.0);
float size = 200.0 * length(viewPos.xyz);
size = clamp(size, 200.0, 2000.0);
gl_PointSize = size;
gl_Position = projectionMatrix * viewPos;
}
`;
let fragmentShader = `
void main() {
vec2 coord = gl_PointCoord - vec2(0.5);
float distance = length(coord);
if(distance > 0.5) {
discard;
}
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
`;
let material = new ShaderMaterial({vertexShader, fragmentShader});
const point = new Points(geometry, material);
point.frustumCulled = false;