Skip to main content

BufferSource

Enum BufferSource 

Source
#[non_exhaustive]
pub enum BufferSource {
Show 19 variants InstanceMatrix, InstanceColor, Range { min: [f64; 4], max: [f64; 4], }, MorphInfluences, UniformArray(Rc<Vec<f32>>), CameraViewMatrices, CameraProjectionMatrices, ClippingIntersection, ClippingUnion, PreviousBoneMatrices, BoneMatrices, Attribute(Rc<Vec<f32>>), Storage, AtomicStorage, Struct { layout: Rc<StructLayout>, init: Rc<Vec<u32>>, }, StorageData { init: Rc<Vec<u32>>, read_only: bool, }, SkeletonBoneMatrices(SkeletonRef), LightProbe(usize), Live(LiveValue),
}
Expand description

Where an array-typed uniform buffer’s contents come from — BufferNode.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

InstanceMatrix

InstancedMesh.instanceMatrix.

§

InstanceColor

InstancedMesh.instanceColor — setColorAt()’s three floats per instance, always a stepMode: 'instance' vertex buffer (three.js wraps it in a fresh InstancedBufferAttribute( colors.array, 3 ) and never takes the uniform branch for it).

§

Range

RangeNode resolved per instance: lerp( min[c], max[c], Math.random() ). min/max are the Vector4s RangeNode.setup() builds out of the min/max values: a scalar splats into all four components, a Color fills xyz and leaves w at 1, and any other vector takes x, y, z || 0, w || 0 — so a vec3 range has w 0 at both ends, not 1.

Fields

§min: [f64; 4]

The low end of the range, one component per channel.

§max: [f64; 4]

The high end of the range, one component per channel.

§

MorphInfluences

Morph.js’ uniformArray( mesh.morphTargetInfluences, 'float' ) — one vec4 per morph target with the influence in .x.

§

UniformArray(Rc<Vec<f32>>)

uniformArray( values ) — a constant array the application supplies, already padded to one vec4 per element the way UniformArrayNode.updateBuffer() pads it. BloomNode.bloomTintColors is the ladder’s first; GodraysNode, SSAONode, GTAONode and SSRNode want the same node.

The values travel in an Rc so the buffer can be cached on the node’s identity and uploaded once, like BufferSource::Attribute.

§

CameraViewMatrices

Camera.js’ uniformArray( matrices ).setGroup( renderGroup ) .setName( 'cameraViewMatrices' ) — every ArrayCamera sub-camera’s matrixWorldInverse, rewritten per render. A render-group buffer, the only one.

§

CameraProjectionMatrices

The same for cameraProjectionMatrices — the sub-cameras’ projectionMatrix.

§

ClippingIntersection

ClippingNode’s uniformArray( intersectionPlanes ).setGroup( renderGroup ) — the clipping context’s intersection planes in view space, one vec4 each, written per draw from the draw’s context.

§

ClippingUnion

The same for the context’s unionPlanes.

§

PreviousBoneMatrices

buffer( previousBoneMatrices, 'mat4', bones ) — Skinning.js’ getPreviousSkinnedPosition(): the skeleton’s bone matrices as they were before this frame’s skeleton.update(), for the positionPrevious of a draw into a velocity MRT.

§

BoneMatrices

referenceBuffer( 'skeleton.boneMatrices', 'mat4', bones ) — the skeleton’s bone matrices as one array< mat4x4<f32>, N >. Three falls back to a bone texture when bones * 64 passes the uniform buffer limit; the ladder’s skeletons fit (Michelle is 65 bones, 4160 bytes).

§

Attribute(Rc<Vec<f32>>)

A per-instance attribute the caller fills itself — three.js’ new InstancedBufferAttribute( array, itemSize ) on the geometry, e.g. BatchedText’s aGlyphUV / aGlyphBounds / aColor / aOpacity. Only ever a vertex buffer: the uniform path has no equivalent.

§

Storage

instancedArray( count, type ) — a GPU-only storage buffer (StorageBufferNode, StorageInstancedBufferAttribute with no array behind it). Zero-filled once by the renderer and never re-uploaded: the only thing that ever writes it is a compute pass.

Declared array< T > with no element count, because WGSLNodeBuilder.getStorageAccess() emits a runtime-sized array; the count on the BufferNode is only what the renderer allocates.

§

AtomicStorage

instancedArray( count, 'uint' ).toAtomic() — BufferSource::Storage whose elements are declared atomic< T > (WGSLNodeBuilder.getUniforms()’s bufferNode.isAtomic arm), so the only way to touch one is an atomic function.

§

Struct

storage( indirectAttribute, struct( … ), count ) — an IndirectStorageBufferAttribute read and written through a named WGSL struct (StructTypeNode). Declared as the struct itself rather than wrapped in { value : array< … > }, which is WGSLNodeBuilder.isCustomStruct()’s single-struct case. init is the attribute’s Uint32Array, uploaded once when the GPU buffer is made; see crate::core::IndirectStorageBufferAttribute.

Fields

§layout: Rc<StructLayout>

The struct’s name and member list.

§init: Rc<Vec<u32>>

The attribute’s initial contents, uploaded once.

§

StorageData

storage( attribute, type, count ) over an attribute that has a CPU array — computeSkinning()’s storage( new InstancedBufferAttribute( position.array, 3 ), 'vec3' ), or a StorageInstancedBufferAttribute( array, itemSize ). Uploaded once, when the GPU buffer is made, then left to the kernels. init is the array’s bits already laid out at the storage stride (a vec3 padded to 16 bytes, as WebGPUAttributeUtils.createAttribute() pads it).

read_only is .toReadOnly(): var<storage, read> in a kernel too.

Fields

§init: Rc<Vec<u32>>

The array’s bits, already laid out at the storage stride.

§read_only: bool

.toReadOnly() — var<storage, read> rather than read_write.

§

SkeletonBoneMatrices(SkeletonRef)

buffer( skeleton.boneMatrices, 'mat4', bones ) — computeSkinning()’s bone matrices: a plain uniform BufferNode over the skeleton’s own array rather than SkinningNode’s referenceBuffer, so it is resolved from the skeleton it names and not from a render object. The skeleton’s OnObjectUpdate (skeleton.update(), once per frame) runs when the buffer is written.

§

LightProbe(usize)

LightProbeNode.lightProbe — uniformArray( 9 × Vector3 ) holding the probe at this index of the renderer’s light list, each coefficient already multiplied by light.intensity (LightProbeNode.update()). One vec4 per coefficient, rewritten per draw like BufferSource::MorphInfluences, because the probe can change between frames while the program does not.

§

Live(LiveValue)

uniformArray( values ) over an array the application keeps changing — LightProbeHelper’s uniformArray( lightProbe.sh.coefficients ), which shares the probe’s own Vector3s. The reader returns the elements already padded to four floats each; the buffer is rewritten per draw. Compares by identity, as UniformSource::Live does.

Trait Implementations§

Source§

impl Clone for BufferSource

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BufferSource

Derived but for Attribute, whose Rc<Vec<f32>> is the caller’s whole per-instance array — BatchedText hands it four floats per glyph.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for BufferSource

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for BufferSource

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BufferSource

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.