三个 Js 简单着色器不工作

Three Js simple Shader not working

我正在尝试 运行 以下带有 three.js

的简单着色器
mat = new THREE.ShaderMaterial({
  uniforms: {
    color: { type: 'v3', value: new THREE.Color(0xcccccc) }
  },
  vertexShader: 'attribute vec3 vert;\n'
              + 'void main() {\n' 
              + '  gl_Position = vec4(vert, 1.0);\n'
              + '}',
  fragmentShader: 'uniform vec3 color;\n'
                + 'void main() {\n'
                + '  gl_FragColor = vec4(color,1);\n'
                + '}'
})

着色器编译但具有此 material 的对象不可见。

这应该以恒定的浅灰色显示对象。

当我 运行 这个和 kick.js shader editor 它按预期工作。

预定义 material 一切都很好。

我是不是漏掉了什么?

你的顶点着色器应该是:

// Multiply each vertex by the model-view matrix and the projection matrix
// (both provided by Three.js) to get a final vertex position. 
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );