Class: ShaderAttribute

SPE. ShaderAttribute

new ShaderAttribute(type, dynamicBufferopt, arrayTypeopt)

A helper to handle creating and updating a THREE.BufferAttribute instance.
Parameters:
Name Type Attributes Description
type String The buffer attribute type. See SPE.ShaderAttribute.typeSizeMap for valid values.
dynamicBuffer Boolean <optional>
Whether this buffer attribute should be marked as dynamic or not.
arrayType function <optional>
A reference to a TypedArray constructor. Defaults to Float32Array if none provided.
Author:
  • Luke Moody
Source:

Members

(static) typeSizeMap :Number

A map of uniform types to their component size.
Type:
  • Number
Properties:
Name Type Description
f Number Float
v2 Number Vec2
v3 Number Vec3
v4 Number Vec4
c Number Color
m3 Number Mat3
m4 Number Mat4
Source:

Methods

_createBufferAttribute(size)

Creates a THREE.BufferAttribute instance if one doesn't exist already. Ensures a typed array is present by calling _ensureTypedArray() first. If a buffer attribute exists already, then it will be marked as needing an update.
Parameters:
Name Type Description
size Number The size of the typed array to create if one doesn't exist, or resize existing array to.
Source:

_ensureTypedArray(size)

Make sure this attribute has a typed array associated with it. If it does, then it will ensure the typed array is of the correct size. If not, a new SPE.TypedArrayHelper instance will be created.
Parameters:
Name Type Description
size Number The size of the typed array to create or update to.
Source:

flagUpdate()

Calculate the number of indices that this attribute should mark as needing updating. Also marks the attribute as needing an update.
Source:

getLength() → {Number}

Returns the length of the typed array associated with this attribute.
Source:
Returns:
The length of the typed array. Will be 0 if no typed array has been created yet.
Type
Number

resetUpdateRange()

Reset the index update counts for this attribute
Source:

setUpdateRange(min, max)

Calculate the minimum and maximum update range for this buffer attribute using component size independant min and max values.
Parameters:
Name Type Description
min Number The start of the range to mark as needing an update.
max Number The end of the range to mark as needing an update.
Source:

splice(start, end)

Perform a splice operation on this attribute's buffer.
Parameters:
Name Type Description
start Number The start index of the splice. Will be multiplied by the number of components for this attribute.
end Number The end index of the splice. Will be multiplied by the number of components for this attribute.
Source: