Skip to content

How do you work with primitives? #3350

Answered by romainguy
davidwarford asked this question in Q&A
Discussion options

You must be logged in to vote

The triangle demo shows how to do it: https://github.com/google/filament/blob/main/web/samples/triangle.html

The relevant code is here:

        const TRIANGLE_POSITIONS = new Float32Array([
            1, 0,
            Math.cos(Math.PI * 2 / 3), Math.sin(Math.PI * 2 / 3),
            Math.cos(Math.PI * 4 / 3), Math.sin(Math.PI * 4 / 3),
        ]);

        const TRIANGLE_COLORS = new Uint32Array([0xffff0000, 0xff00ff00, 0xff0000ff]);

        this.vb = Filament.VertexBuffer.Builder()
            .vertexCount(3)
            .bufferCount(2)
            .attribute(VertexAttribute.POSITION, 0, AttributeType.FLOAT2, 0, 8)
            .attribute(VertexAttribute.COLOR, 1, AttributeType.UBYTE4, 0,

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@davidwarford
Comment options

Comment options

You must be logged in to vote
1 reply
@davidwarford
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by davidwarford
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants