ShaderAttribute Class

Module: Lights

A helper to handle creating and updating a BufferAttribute instance.

Constructor

ShaderAttribute

(
  • type
  • dynamicBuffer
  • arrayType
)

Parameters:

  • type String

    The buffer attribute type. See ShaderAttribute.typeSizeMap for valid values.

  • dynamicBuffer Boolean

    Whether this buffer attribute should be marked as dynamic or not.

  • arrayType Function

    A reference to a TypedArray constructor. Defaults to Float32Array if none provided.

Methods

_createBufferAttribute

(
  • size
)

Creates a 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:

  • size Number

    The size of the typed array to create if one doesn't exist, or resize existing array to.

_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 TypedArrayHelper instance will be created.

Parameters:

  • size Number

    The size of the typed array to create or update to.

flagUpdate

()

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

getLength

() Number

Returns the length of the typed array associated with this attribute.

Returns:

Number:

The length of the typed array. Will be 0 if no typed array has been created yet.

resetUpdateRange

()

Reset the index update counts for this attribute

setUpdateRange

(
  • min
  • max
)

Calculate the minimum and maximum update range for this buffer attribute using component size independant min and max values.

Parameters:

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

splice

(
  • start
  • end
)

Perform a splice operation on this attribute"s buffer.

Parameters:

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

Attributes

typeSizeMap

static

A map of uniform types to their component size.