// 顶点着色器代码
const vertex = `
// attribute vec2 uv;
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`;
// 片元着色器代码
const fragment = `
varying vec2 vUv;
void main() {
// vec2 st = gl_FragCoord.xy/vUv;
float pct = 0.0;
pct = distance(vUv,vec2(0.5));
vec3 color = vec3(pct);
gl_FragColor = vec4(color, 0.1);
}
`;
const uniforms = {
uTime: { value: 1.0 }
};
const material = new ShaderMaterial({
vertexShader: vertex,
fragmentShader: fragment
});
const plane = new Mesh(planeGeo, material);
plane.position.set(spot[0], spot[1], spot[2] + 0.4);
// plane.rotation.x = Math.PI / 2;
circleGroup.add(plane);
其中 vUv代替r3f中的uv
logarithmicDepthBuffer 需要关闭,防止其显示不正确