Attribute

clay.GeometryBase. Attribute

# new Attribute()

Source:

GeometryBase attribute

Members

# name :string

Source:

Attribute name

Type:
  • string

# semantic :string

Source:

Semantic of this attribute. Possible values:

  • 'POSITION'
  • 'NORMAL'
  • 'BINORMAL'
  • 'TANGENT'
  • 'TEXCOORD'
  • 'TEXCOORD_0'
  • 'TEXCOORD_1'
  • 'COLOR'
  • 'JOINT'
  • 'WEIGHT'

In shader, attribute with same semantic will be automatically mapped. For example:

attribute vec3 pos: POSITION

will use the attribute value with semantic POSITION in geometry, no matter what name it used.

Type:
  • string

# size :number

Source:

Size of attribute component. 1 - 4.

Type:
  • number

# type :string

Source:

Attribute type Possible values:

  • 'byte'
  • 'ubyte'
  • 'short'
  • 'ushort'
  • 'float' Most commonly used.
Type:
  • string

# value :TypedArray

Source:

Value of the attribute.

Type:
  • TypedArray

Methods

# fromArray(array)

Source:

Initialize attribute with given array. Which can be 1 dimensional or 2 dimensional

Example
geometry.getAttribute('position').fromArray(
     [-1, 0, 0, 1, 0, 0, 0, 1, 0]
 );
 geometry.getAttribute('position').fromArray(
     [ [-1, 0, 0], [1, 0, 0], [0, 1, 0] ]
 );
Parameters:
Name Type Description
array Array

# init(nVertex)

Source:

Initialize attribute with given vertex count

Parameters:
Name Type Description
nVertex number

# set(idx, val)

Source:

Set item value at give index. Second parameter val is number if size is 1

Example
geometry.getAttribute('position').set(0, [1, 1, 1]);
Parameters:
Name Type Description
idx number
val Array.<number> | number

# set(idx, outopt)

Source:

Get item value at give index. Second parameter out is no need if size is 1

Example
geometry.getAttribute('position').get(0, out);
Parameters:
Name Type Attributes Description
idx number
out Array.<number> <optional>