API Reference

Class List

pc.Mat3

A 3x3 matrix.

Summary

Static Properties

IDENTITYA constant matrix set to the identity.[read only]
ZEROA constant matrix with all elements set to 0.[read only]

Methods

cloneCreates a duplicate of the specified matrix.
copyCopies the contents of a source 3x3 matrix to a destination 3x3 matrix.
equalsReports whether two matrices are equal.
isIdentityReports whether the specified matrix is the identity matrix.
setCopies the contents of a source array[9] to a destination 3x3 matrix.
setIdentitySets the matrix to the identity matrix.
toStringConverts the matrix to string form.
transposeGenerates the transpose of the specified 3x3 matrix.

Details

Static Properties

IDENTITYA constant matrix set to the identity.[read only]
ZEROA constant matrix with all elements set to 0.[read only]

Constructor

Mat3()

Creates a new identity Mat3 object.

Methods

clone()

Creates a duplicate of the specified matrix.

var src = new pc.Mat3().translate(10, 20, 30);
var dst = src.clone();
console.log("The two matrices are " + (src.equals(dst) ? "equal" : "different"));

Returns

pc.Mat3 A duplicate matrix.

copy(rhs)

Copies the contents of a source 3x3 matrix to a destination 3x3 matrix.

var src = new pc.Mat3().translate(10, 20, 30);
var dst = new pc.Mat3();
dst.copy(src);
console.log("The two matrices are " + (src.equals(dst) ? "equal" : "different"));

Parameters

rhspc.Mat3A 3x3 matrix to be copied.

Returns

pc.Mat3 Self for chaining

equals(rhs)

Reports whether two matrices are equal.

var a = new pc.Mat3().translate(10, 20, 30);
var b = new pc.Mat3();
console.log("The two matrices are " + (a.equals(b) ? "equal" : "different"));

Parameters

rhspc.Mat3The other matrix.

Returns

Boolean true if the matrices are equal and false otherwise.

isIdentity()

Reports whether the specified matrix is the identity matrix.

var m = new pc.Mat3();
console.log("The matrix is " + (m.isIdentity() ? "identity" : "not identity"));

Returns

Boolean true if the matrix is identity and false otherwise.

set(src)

Copies the contents of a source array[9] to a destination 3x3 matrix.

var src = [0, 1, 2, 3, 4, 5, 6, 7, 8];
var dst = new pc.Mat3();
dst.copy(src);

Parameters

srcArrayAn array[9] to be copied.

Returns

pc.Mat3 Self for chaining

setIdentity()

Sets the matrix to the identity matrix.

m.setIdentity();
console.log("The matrix is " + (m.isIdentity() ? "identity" : "not identity"));

Returns

pc.Mat3 Self for chaining.

toString()

Converts the matrix to string form.

var m = new pc.Mat3();
// Should output '[1, 0, 0, 0, 1, 0, 0, 0, 1]'
console.log(m.toString());

Returns

String The matrix in string form.

transpose()

Generates the transpose of the specified 3x3 matrix.

var m = new pc.Mat3();

// Transpose in place
m.transpose();

Returns

pc.Mat3 Self for chaining.