Attribute (Internal)
This class helps deck.gl manage attributes. It integrates into the luma.gl Model.setAttributes()
method by implementing the Attribute.getValue()
method. luma.gl checks for the presence of this method on any attribute passed in.
Usage
Create model object by passing shaders, uniforms, geometry and render it by passing updated uniforms.
import {Attribute} from '@deck.gl/core';
// construct the model.
const positions = new Attribute({
id: 'vertexPositions',
size: 3,
value: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0])
});
// and on each frame update any uniforms (typically matrices) and call render.
model.setAttributes({positions});
model.draw();
Methods
constructor
The constructor for the Attribute class. Use this to create a new Attribute.
new Attribute(gl, options);
gl
- WebGL context.size
(number) - The number of components in each element the buffer (1-4).id
(string, optional) - Identifier of the attribute. Cannot be updated.type
(string, optional) - Type of the attribute. If not supplied will be inferred fromvalue
. Cannot be updated.isIndexed
(boolean, optional) - If the attribute is element index. Defaultfalse
. Cannot be updated.constant
(boolean, optional) - If the attribute is a constant. Defaultfalse
.isInstanced
(boolean, optional) - Whether buffer contains instance data. Defaultfalse
.normalized
(boolean, optional) - Defaultfalse
integer
(boolean, optional) - Defaultfalse
offset
(number, optional) - where the data starts in the buffer. Default0
.stride
(number, optional) - an additional offset between each element in the buffer. Default0
.value
(TypedArray) - value of the attribute.- If
constant
istrue
, the length ofvalue
should matchsize
- If
constant
isfalse
, the length ofvalue
should besize
multiplies the number of vertices.
- If
buffer
(Buffer) - an external buffer for the attribute.
delete
Free GPU resources associated with this attribute.
update
attribute.update({value: newValue});
Update attribute options. See constructor
for possible options.
getBuffer
Returns a Buffer
object associated with this attribute, if any.