Simple object pool for immediate mode rendering using the WebAPI #4531
redstonedash
started this conversation in
Show and tell
Replies: 1 comment
-
function createRenderable(mesh, bounds, matinstance) {
const renderable = Filament.EntityManager.get().create();
const engine = this.engine;
const vertices = mesh.vertices;
const tangents = mesh.tangents;
const triangles = mesh.triangles;
const vb = Filament.VertexBuffer.Builder()
.vertexCount(vertices.length / 3)
.bufferCount(2)
.attribute(Filament.VertexAttribute.POSITION, 0, Filament.VertexBuffer$AttributeType.FLOAT3, 0, 0)
.attribute(Filament.VertexAttribute.TANGENTS, 1, Filament.VertexBuffer$AttributeType.SHORT4, 0, 0)
.normalized(Filament.VertexAttribute.TANGENTS)
.build(engine);
const ib = Filament.IndexBuffer.Builder()
.indexCount(triangles.length)
.bufferType(Filament.IndexBuffer$IndexType.USHORT)
.build(engine);
vb.setBufferAt(engine, 0, vertices);
vb.setBufferAt(engine, 1, tangents);
ib.setBuffer(engine, triangles);
Filament.RenderableManager.Builder(1)
.boundingBox(bounds)
.material(0, matinstance)
.geometry(0, Filament.RenderableManager$PrimitiveType.TRIANGLES, vb, ib)
.build(engine, renderable);
return renderable;
} left this out |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The usage is simple, call draw object to draw a sphere, then at the end of the frame call frame end.
Beta Was this translation helpful? Give feedback.
All reactions