pub struct InstancedBufferAttribute {
pub item_size: usize,
/* private fields */
}Expand description
new InstancedBufferAttribute( new Float32Array( count * 16 ), 16 ).
The renderer keeps one GPU buffer per attribute, keyed on id,
and writes into it only when version has moved since the
last write, as three.js’ Attributes.update() does (issue #89).
Unlike three.js, a write through this type bumps the version itself:
array_mut always does, and setMatrixAt() /
setColorAt() do when the value they write differs from the one there.
three.js needs attribute.needsUpdate = true because its Float32Array is
mutated behind the attribute’s back; here every write goes through the
attribute, so a second call would only add a stale-frame footgun, the same
reasoning as Texture::set_data (docs/api.md).
set_needs_update stays, for forcing a write.
clone() mints a fresh id, as a cloned BufferAttribute does, and shares
the array until one side writes to it.
Fields§
§item_size: usizeBufferAttribute.itemSize.
Implementations§
Source§impl InstancedBufferAttribute
impl InstancedBufferAttribute
Sourcepub fn new(array: Vec<f32>, item_size: usize) -> Self
pub fn new(array: Vec<f32>, item_size: usize) -> Self
new InstancedBufferAttribute( array, itemSize ).
Sourcepub fn array_mut(&mut self) -> &mut [f32]
pub fn array_mut(&mut self) -> &mut [f32]
attribute.array, for writing. Bumps the version, so the next render
re-writes the GPU buffer: the caller is taken to have changed something.
Sourcepub fn version(&self) -> u32
pub fn version(&self) -> u32
BufferAttribute.version — how many times the array has been changed
or marked changed.
Sourcepub fn set_needs_update(&mut self)
pub fn set_needs_update(&mut self)
attribute.needsUpdate = true — version ++, so the next render
re-writes the GPU buffer even though nothing was written through
array_mut.