RealityMeshParamsBuilder Class @beta
Incrementally constructs a RealityMeshParams. The following simple example produces a rectangular mesh containing two triangles.
export function buildRealityMeshParams(): RealityMeshParams {
  // Create the builder.
  const builder = new RealityMeshParamsBuilder({
    // Our mesh contains 4 vertices.
    initialVertexCapacity: 4,
    // Our mesh contains 2 triangles with 3 indices each.
    initialIndexCapacity: 6,
    // Our meshes positions all fall within [(0,0,0), (10,5,0)].
    positionRange: new Range3d(0, 0, 0, 10, 5, 0),
  });
  // Add the 4 corners of the rectangle.
  builder.addVertex({x:0, y:0, z:0}, {x:0, y:0});
  builder.addVertex({x:10, y:0, z:0}, {x:1, y:0});
  builder.addVertex({x:10, y:5, z:0}, {x:1, y:1});
  builder.addVertex({x:0, y:5, z:0}, {x:0, y:1});
  // Add the two triangles describing the rectangle.
  builder.addTriangle(0, 1, 2);
  builder.addTriangle(0, 2, 3);
  // Extract the RealityMeshParams.
  return builder.finish();
}
Methods
| Name | Description | |
|---|---|---|
| constructor(options: RealityMeshParamsBuilderOptions): RealityMeshParamsBuilder | Construct a builder from the specified options. | |
| addIndices(indices: Iterable<number, any, any>): void | Add all of the indices in indicesto the index buffer. | |
| addQuad(i0: number, i1: number, i2: number, i3: number): void | Add two triangles sharing an edge. | |
| addQuantizedVertex(position: Readonly<WritableXYAndZ>, uv: Readonly<WritableXAndY>, normal?: number): number | Add a vertex to the mesh and return its index in positions. | |
| addTriangle(i0: number, i1: number, i2: number): void | Add a triangle corresponding to the three specified vertices. | |
| addUnquantizedVertex(position: Readonly<WritableXYAndZ>, uv: Readonly<WritableXAndY>, normal?: Readonly<WritableXYAndZ>): number | Add a vertex to the mesh and return its index in positions. | |
| finish(): RealityMeshParams | Extract the finished RealityMeshParams. | 
Properties
| Name | Type | Description | |
|---|---|---|---|
| indices Readonly | UintArrayBuilder | The indices of the vertices in each triangle of the mesh. | |
| normals | Uint16ArrayBuilder | undefined | The normal vector of each vertex in the mesh, or undefinedif wantNormals was nottruewhen constructing the builder. | |
| positions Readonly | QPoint3dBufferBuilder | The 3d position of each vertex in the mesh. | |
| uvs Readonly | QPoint2dBufferBuilder | The 2d texture coordinates of each vertex in the mesh. | 
Defined in
Last Updated: 24 June, 2025
Found something wrong, missing, or unclear on this page? Raise an issue in our repo.