MeshAttributeData

View source

Represents the numeric vertex data for a mesh attribute.

Examples

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


constructor(data: Float32Array<ArrayBufferLike>)

View source

Creates a mesh attribute buffer value.

Parameters

NameDescriptionDefault
data——

Properties


data: Float32Array<ArrayBufferLike>

View source

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.

Methods


staticserialize(value: MeshAttributeData): MeshAttributeDataSerial

View source

Converts 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.

Parameters

NameDescriptionDefault
value——

staticdeserialize(value: MeshAttributeDataSerial, out?: MeshAttributeData): MeshAttributeData

View source

Restores 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.

Parameters

NameDescriptionDefault
value——
out?—...

staticvalidateSerial(value: unknown): value is MeshAttributeDataSerial

View source

Checks 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.

Parameters

NameDescriptionDefault
value——