我正在尝试将自定义着色器与 Three.js 一起使用。我试着像许多例子一样做,但它不起作用。我的代码是:
var vertex = "void main(){vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );gl_Position = projectionMatrix * mvPosition;}";
var fragment = "precision highp float;void main(void){gl_FragColor = vec4(0.0,1.0,0.0,1.0);}";
material = new THREE.ShaderMaterial({
vertexShader: vertex,
fragmentShader: fragment
});
var mesh = new THREE.Mesh(geometry,material);
……一切都是空白的。但如果我使用这种材料:
material = new THREE.MeshBasicMaterial({ color: 0xff0000, wireframe: true });
……一切都很完美。怎么了?