Type Alias GeometryArrays

GeometryArrays: {
    indices?: IntArrayParam;
    normals?: FloatArrayParam;
    positions: FloatArrayParam;
    primitive: number;
    uv?: FloatArrayParam;
}

Geometry data arrays.

This type represents the arrays used to define the geometry of a 3D object in the scene, including its primitive type, positions, normals, UV coordinates, and indices. These arrays are typically used by scene rendering engines to define the shape of objects.

  • primitive: The primitive type of the geometry. This value can represent various geometric primitives such as lines, triangles, etc.
  • positions: An array of 3D coordinates (x, y, z) that define the vertices of the geometry.
  • normals: An optional array of normals, which are vectors that are perpendicular to the surface of the geometry. Normals are used for lighting calculations. If not provided, the geometry will not have normals.
  • uv: An optional array of UV coordinates, which map the geometry's vertices to a 2D texture. If not provided, the geometry will not have textures.
  • indices: An optional array of indices that define how the vertices are connected to form the faces of the geometry. If not provided, the geometry may be treated as a point or line.

A typical geometry configuration is created by a builder function like buildGridGeometry or buildPlaneGeometry, which populate the positions, normals, uv, and indices arrays. The data is then returned in this GeometryArrays format and can be used for rendering in a 3D scene.

For example, when building a plane geometry:

const planeGeometry = buildPlaneGeometry({
xSize: 10,
zSize: 10,
xSegments: 10,
zSegments: 10,
center: [0, 0, 0]
});
// planeGeometry will be of type GeometryArrays, containing positions, normals, UVs, and indices

The following is an example of what a GeometryArrays object might look like:

{
primitive: 20002, // TrianglesPrimitive
positions: [0, 0, 0, 1, 0, 0, 0, 1, 0],
normals: [0, 0, 1, 0, 0, 1, 0, 0, 1],
uv: [0, 0, 1, 0, 0, 1],
indices: [0, 1, 2]
}
  • The positions array must always be populated since it defines the geometry's vertices.
  • Normals, UVs, and indices are optional and only necessary for specific types of geometry (e.g., for texturing or lighting calculations).

Type declaration