Class: Vec1Array

Vec1Array

Array of 32-bit floats. May reflect an ESSL array-of-floats uniform variable.
Individual Vec1 elements are available through the at method. Methods are available for optimized bulk processing.

new Vec1Array(size)

Parameters:
Name Type Description
size Number The number of Vec1 elements in the array.

Extends

Methods


add(b, c)

Adds vectors from the two argument arrays, storing the result in this array.
Parameters:
Name Type Description
b VecArray Array of first terms. Its length must be identical to this array's length.
c VecArray Array of second terms. Its length must be identical to this array's length.
Inherited From:
Returns:
this
Type
VecArray

addAll(b, c)

Adds a vector to all argument array elements, storing the result in this array.
Parameters:
Name Type Description
b VecArray Array of first operands. Same length as this.
c Vec Second operand.
Inherited From:
Returns:
this
Type
VecArray

addScaled(b, c, dt)

Adds vectors from the two argument arrays, scaling the second arguments, storing the result in this array.
Parameters:
Name Type Description
b VecArray Array of first terms. Its length must be identical to this array's length.
c VecArray Array of second terms. Its length must be identical to this array's length.
dt Number Single scalar scaling factor.
Inherited From:
Returns:
this
Type
VecArray

at(index)

Returns a new Vec1 object that captures an element of the array. The new vector is a view on the original data, not a copy.
Parameters:
Name Type Description
index Number Index of the element.
Returns:
new view on one of the array's elements
Type
Vec1

clamp()

Constrains values in the array to the [0,1) interval.
Inherited From:
Returns:
this
Type
VecArray

commit(gl, uniformLocation)

Sets the value of the vector array to a WebGL vec1 array uniform variable.
Parameters:
Name Type Description
gl WebGLRenderingContext rendering context
uniformLocation WebGLUniformLocation location of the uniform variable in the currently used WebGL program

div(b, c)

Divides, elementwise, vectors from the two argument arrays, storing the result in this array.
Parameters:
Name Type Description
b VecArray Array of dividends.
c VecArray Array of divisors.
Inherited From:
Returns:
this
Type
VecArray

divAll(b, c)

Divides (elementwise) all argument array elements with a vector, storing the result in this array.
Parameters:
Name Type Description
b VecArray Array of first operands. Same length as this.
c Vec Second operand.
Inherited From:
Returns:
this
Type
VecArray

divWithVec1s(b, c)

Divides, elementwise, vectors from the two argument arrays, repeating individual values of the second one to produce the same number of values as in the output array.
Parameters:
Name Type Description
b VecArray Array of dividends. Its length must be identical to this array's length.
c Vec1Array Array of divisors. Its length must be identical to this array's length.
Inherited From:
Returns:
this
Type
VecArray

dotAllVec2s(b, c)

Computes the dot product of two-element vectors from the two argument arrays, in every possible combination, storing the result in this array. First all elements of `b` are paired with the first element in `c`, then with the second element in `c`, and so on. 'a.length == b.length * c.length' is assumed. 'b' or 'c' can be vectors instead of arrays, in which case all elements of the other array are paired with the same value, once.
Parameters:
Name Type Description
b Vec2Array | Vec2 Array of first operands, or a single term.
c Vec2Array | Vec2 Array of operands, or a single term.
Returns:
this
Type
Vec1Array

dotAllVec3s(b, c)

Computes the dot product of three-element vectors from the two argument arrays, in every possible combination, storing the result in this array. First all elements of `b` are paired with the first element in `c`, then with the second element in `c`, and so on. 'a.length == b.length * c.length' is assumed. 'b' or 'c' can be vectors instead of arrays, in which case all elements of the other array are paired with the same value, once.
Parameters:
Name Type Description
b Vec3Array | Vec3 Array of first operands, or a single term.
c Vec3Array | Vec3 Array of operands, or a single term.
Returns:
this
Type
Vec1Array

dotAllVec4s(b, c)

Computes the dot product of three-element vectors from the two argument arrays, in every possible combination, storing the result in this array. First all elements of `b` are paired with the first element in `c`, then with the second element in `c`, and so on. 'a.length == b.length * c.length' is assumed. 'b' or 'c' can be vectors instead of arrays, in which case all elements of the other array are paired with the same value, once.
Parameters:
Name Type Description
b Vec4Array | Vec3 Array of first operands, or a single term.
c Vec4Array | Vec3 Array of operands, or a single term.
Returns:
this
Type
Vec1Array

dotVec2s(b, c)

Computes the dot products of two two-element vectors in arrays, and stores the result.
Parameters:
Name Type Description
b Vec2Array Array of first operands.
c Vec2Array Array of second operands.
Returns:
this

dotVec3s(b, c)

Computes the dot products of two three-element vectors in arrays, and stores the result.
Parameters:
Name Type Description
b Vec3Array Array of first operands.
c Vec3Array Array of second operands.
Returns:
this

dotVec4s(b, c)

Computes the dot products of two four-element vectors in arrays, and stores the result.
Parameters:
Name Type Description
b Vec4Array Array of first operands.
c Vec4Array Array of second operands.
Returns:
this

exp(b, c)

Exponentiates vectors from an array with a scalar, storing the result in this array. For scaling with factors stored in an array, see mulAll.
Parameters:
Name Type Description
b VecArray Array of vectors to scale. Its length must be identical to this array's length.
c VecArray Exponent.
Inherited From:
Returns:
this
Type
VecArray

mul(b, c)

Multipies, elementwise, vectors from the two argument arrays, storing the result in this array.
Parameters:
Name Type Description
b VecArray Array of factors. Its length must be identical to this array's length.
c VecArray Array of factors. Its length must be identical to this array's length.
Inherited From:
Returns:
this
Type
VecArray

mulAll(b, c)

Multiplies (elementwise) a vector with all argument array elements, storing the result in this array.
Parameters:
Name Type Description
b VecArray Array of first operands. Same length as this.
c Vec Second operand.
Inherited From:
Returns:
this
Type
VecArray

mulWithVec1s(b, c)

Multipies, elementwise, vectors from the two argument arrays, repeating individual values of the second one to produce the same number of elements as in the output array. For scaling with a single scalar factor, see scale.
Parameters:
Name Type Description
b VecArray Array of factors. Its length must be identical to this array's length.
c Vec1Array Array of factors. Its length must be identical to this array's length.
Inherited From:
Returns:
this
Type
VecArray

random()

Fills the array with random values between 0 and 1.
Inherited From:
Returns:
this
Type
VecArray

scale(b, c)

Multipies vectors from an array with a scalar, storing the result in this array. For scaling with factors stored in an array, see mulAll.
Parameters:
Name Type Description
b VecArray Array of vectors to scale. Its length must be identical to this array's length.
c VecArray Scale factor.
Inherited From:
Returns:
this
Type
VecArray

set(data)

Sets the value of the vector array from another WebGLMath vector, vector array, matrix, or matrix array object, or an array of numbers.
Parameters:
Name Type Description
data Array.<number> | Object Input data.
Inherited From:

sub(b, c)

Subtracts vectors from the two argument arrays, storing the result in this array.
Parameters:
Name Type Description
b VecArray Array of minuends. Its length must be identical to this array's length.
c VecArray Array of subtrahends. Its length must be identical to this array's length.
Inherited From:
Returns:
this
Type
VecArray

subAll(b, c)

Subtracts a vector from all argument array elements, storing the result in this array.
Parameters:
Name Type Description
b VecArray Array of first operands. Same length as this.
c Vec Second operand.
Inherited From:
Returns:
this
Type
VecArray

subarray( [begin] [, end])

Returns a new Vec1Array object that captures a subrange of the array. The new array is a view on the original data, not a copy.
Parameters:
Name Type Argument Default Description
begin Number <optional>
0 Element to begin at. The offset is inclusive. The whole array will be cloned if this value is not specified.
end Number <optional>
length Element to end at. The offset is exclusive. If not specified, all elements from the one specified by begin to the end of the array are included in the new view.
Returns:
new view on some of the array's elements
Type
Vec1Array