给物体添加自发光线框
export function makeOutlineLoop(points: THREE.Vector3[]) {
// 自发光材质
const material = new THREE.ShaderMaterial({
vertexShader: `
varying vec3 vPosition;
void main() {
vPosition = position;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,
fragmentShader: `
varying vec3 vPosition;
void main() {
float brightness = 1.0; // 自发光亮度调整
vec3 color = vec3(0.63, 0.63, 0.97); // 自发光颜色
gl_FragColor = vec4(color * brightness, 1.0);
}
`,
transparent: true,
depthTest: false,
depthWrite: false
});
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const outline = new THREE.LineLoop(geometry, material);
return outline;
}