constructor(data: Float32Array<ArrayBufferLike>)
View sourceCreates a mesh attribute buffer value.
Class
Represents the numeric vertex data for a mesh attribute.
import { Mesh, MeshAttributeData } from '@wimaengine/render-core'
const mesh = new Mesh()
mesh.setAttribute('uv', new MeshAttributeData(new Float32Array([
0, 0, 1, 0, 1, 1
])))constructor(data: Float32Array<ArrayBufferLike>)Creates a mesh attribute buffer value.
Numeric values supplied to the named mesh attribute.
The constructor stores the supplied typed array directly, so mutations to that array are visible through this value and to a mesh using it.
serialize(value: MeshAttributeData): MeshAttributeDataSerialConverts the attribute buffer to its plain serial representation.
The returned object contains a new number array made from data; the
typed array and the value are not mutated.
deserialize(value: MeshAttributeDataSerial, out?: MeshAttributeData): MeshAttributeDataRestores an attribute buffer from its plain serial representation.
When out is supplied, its data field is replaced with a new
Float32Array. Without out, the method creates an empty target first.
The populated target is returned.
validateSerial(value: unknown): value is MeshAttributeDataSerialChecks whether a value has the serialized attribute-buffer shape.
This requires an object with a data property whose value is an array.
It does not inspect the array’s elements or construct a
MeshAttributeData instance.