Reputation: 14534
For the buffer geometry example here, if I change position to position1, it does not work at all.
var geometry = new THREE.BufferGeometry();
// create a simple square shape. We duplicate the top left and bottom right
// vertices because each vertex needs to appear once per triangle.
var vertices = new Float32Array( [
-1.0, -1.0, 1.0,
1.0, -1.0, 1.0,
1.0, 1.0, 1.0,
1.0, 1.0, 1.0,
-1.0, 1.0, 1.0,
-1.0, -1.0, 1.0
] );
// itemSize = 3 because there are 3 values (components) per vertex
geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
// I can't change the string 'position' to 'position1', why?
var material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
var mesh = new THREE.Mesh( geometry, material );
Clearly, 'position' is the keyword that is used internally for a list of vertexes. I assume the position will be passed to vertex shader, is this correct?
What are the list of keyword for InstancedBufferGeometry, like the 'position'?
Upvotes: 1
Views: 40
Reputation: 210968
See WebGLProgram. Built-in attributes are:
attribute vec3 position; attribute vec3 normal; attribute vec2 uv;
Which are the vertex coordinate, normal vector and texture coordinate (There are further attributes for morphing and skinning).
If you use a ShaderMaterial, then you can use Your own vertex and fragment shader, custom attributes and use any name you want.
Upvotes: 1