This is how the color is set:
Is this correct?
context.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, colorVector);
This is the main function which draws triangles:
public function set color(value:uint):void
{
_color = value;
colorVector[0] = (_color >> 16) / 255;
colorVector[1] = ((_color & 0x00FF00) >> 8) / 255;
colorVector[2] = (_color & 0x0000FF) / 255;
}
private static var textureLen:int;
private static var i:int;
public function drawTriangles(context:Context3D,
matrix:Matrix3D,
vertexBuffer:VertexBuffer3D,
indexBuffer:IndexBuffer3D,
alpha:Number = 1,
numTriangles:int = -1):void
{
context.setVertexBufferAt(0, vertexBuffer, 0, Context3DVertexBufferFormat.FLOAT_3);
context.setVertexBufferAt(1, vertexBuffer, 3, Context3DVertexBufferFormat.FLOAT_4);
context.setVertexBufferAt(2, vertexBuffer, 7, Context3DVertexBufferFormat.FLOAT_2);
if(program == null && _vertexShader && _fragmentShader)
{
program = Program3DCache.getProgram3D(context, _vertexShader, _fragmentShader);
}
context.setProgram(program);
textureLen = _textures.length;
for(i = 0; i < 8; i++)
{
context.setTextureAt( i, i < textureLen ? _textures[i].base : null );
}
context.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 0, matrix, true);
_vertexShader.setConstants(context, 4);
colorVector[3] = _alpha*alpha;// Multiply display obect's alpha by material alpha.
context.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, colorVector);
_fragmentShader.setConstants(context, 1);
context.drawTriangles(indexBuffer, 0, numTriangles);
}