Custom Geometry
Build geometry from raw vertex data using Attribute and Geometry.
import * as EASEL from "easel";
const positions = new Float32Array([
0.0, 1.5, 0.0, // top
-1.0, 0.0, 1.0, // front-left
1.0, 0.0, 1.0, // front-right
1.0, 0.0, -1.0, // back-right
-1.0, 0.0, -1.0, // back-left
0.0, -1.5, 0.0, // bottom
]);
const indices = [
0,1,2, 0,2,3, 0,3,4, 0,4,1,
5,2,1, 5,3,2, 5,4,3, 5,1,4,
];
const geometry = new EASEL.Geometry();
geometry.setAttribute("position", new EASEL.Attribute(positions, 3));
geometry.setIndex(indices);
geometry.computeVertexNormals();
const mesh = new EASEL.Mesh(
geometry,
new EASEL.LambertMaterial({ color: 0xe0a040 }),
);
scene.add(mesh);