Show contents 

Working with Graphic Elements > Classes > Matrix4 > Matrix4.setPerspective

Matrix4.setPerspective

Syntax

setPerspective(fovy: number, aspect: number, znear: number, zfar: number);

Parameters

fovy. Viewing vertical angle in degrees.

aspect. Aspect ratio.

znear. Distance between a camera to the near clipping plane.

zfar. Distance between a camera and far clipping plane.

Description

The setPerspective method sets perspective projection matrix.

Example

To execute this example, in the HEAD tag of HTML page specify links to the following JS and CSS files: PP.js, PP.GraphicBase.js. Create a new matrix:

// Create a matrix
matrix = new PP.Matrix4([
4.717621803283691, 0, 0, 0, 
0, 10.385396957397461, 0, 0,
0, 0, -1.0000020265579224, -1, 
0, 0, -0.002000001957640052, 0
]);
// Set perspective projection
matrix.setPerspective(90, 1, 5, 10);
// Get matrix values
matrix.getData();
// -> [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -3, -1, 0, 0, -20, 0]

After executing the example, perspective projection matrix is set.

See also:

Matrix4