Interface MeshFromStorageOptions
arrayStride: number;
attributeOffsets?: Partial<
Record<
"position"
| "normal"
| "tangent"
| "uv"
| "uv2"
| "color",
number,
>,
>;
baseVertex?: number;
boundMax?: readonly [number, number, number];
boundMin?: readonly [number, number, number];
indexCount?: number;
indexFormat?: GPUIndexFormat;
indices:
| StorageBuffer
| Uint32Array<ArrayBufferLike>
| Uint16Array<ArrayBufferLike>;
storage: StorageBuffer;
vertexCount: number;
}
Properties
Readonlyarray Stride
Byte stride of one vertex inside storage. A positive multiple of four within the device's vertex-stride limit.
Optional Readonlyattribute Offsets
Record<
"position"
| "normal"
| "tangent"
| "uv"
| "uv2"
| "color",
number,
>,
>
Own-property byte offsets inside one vertex. Values must be non-negative integers smaller than arrayStride.
Omitted position, normal, and UV attributes sit at offset 0,
which is the right default when a single float32x4 position is the whole vertex.
Only the six streams MeshVbLayout describes can be offset (position, normal,
tangent, uv, uv2, color); skinning attributes are not supported from a slab.
Optional Readonlybase Vertex
First vertex of this mesh within a shared allocation.
This is how many meshes share ONE slab: each takes a slot and addresses it
through the draw call's baseVertex, rather than a non-zero setVertexBuffer
bind offset (which corrupts vertex fetch on some AMD/Dawn paths). Default 0.
Optional Readonlybound Max
Analytic upper bound of the produced geometry, in mesh-local space.
Optional Readonlybound Min
Analytic lower bound of the produced geometry, in mesh-local space.
Optional Readonlyindex Count
Number of indices to draw. Required when indices is a shared allocation, since
its byte length is padded and need not equal the draw count. Defaults to the
typed array's length. Must be a positive integer within the source capacity.
Every used typed-array index must be less than vertexCount.
Optional Readonlyindex Format
Index format. Derived from the typed array's element size when indices is one
(an explicit format must match);
REQUIRED when indices is a shared allocation, whose element size is not recoverable
from the allocation. A 16-bit topology declared as 32-bit fails WebGPU validation with
a size complaint that points at the buffer rather than at the format.
Readonlyindices
Triangle indices.
A Uint16Array or Uint32Array is snapshotted and uploaded into a fresh index
buffer owned by this mesh. The used prefix is validated for the initial upload;
later changes to the caller's array do not change the uploaded topology.
A StorageBuffer created with { index: true } is used in place, SHARED with
every other mesh given the same allocation. That is the right form for a slab of
uniform slots, where every slot's indices are byte-identical and uploading them
per mesh would duplicate the same kilobytes thousands of times. A shared
allocation is NOT freed with the mesh; it outlives the meshes and the caller
disposes it.
Readonlystorage
Vertex source. Must be vertex: true; GPU-written sources also require writable: true.
Readonlyvertex Count
Logical vertex count in this mesh's slot, used for range validation and missing-stream defaults.
Describes a mesh whose vertices are produced on the GPU.