Projection.perspective

Syntax

perspective(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 perspective method sets perspective projection.

Example

To execute the example the HTML page must contain the MapChart component map (see Example of Creating the MapChart Component). Open a spherical map. Get projection matrix:

// Get class object used to work with 3D projection
var projection = map.getGLControl().getProjection();
// Get projection matrix
console.log("Projection matrix: ");
console.log(projection.getProjectionMatrix().getData());

As a result the console displays projection matrix:

Projection matrix:

[4.717621803283691, 0, 0, 0, 0, 10.385396957397461, 0, 0, 0, 0, -1.0000020265579224, -1, 0, 0, -0.002000001957640052, 0]

 

Set perspective projection and get a new projection matrix:

// Set perspective projection
projection.perspective(30, 4, 100, 200);
// Get a new projection matrix
console.log("Projection matrix: ");
console.log(projection.getProjectionMatrix().getData());

As a result the console displays projection matrix:

Projection matrix:

[0.9330127239227295, 0, 0, 0, 0, 3.732050895690918, 0, 0, 0, 0, -3, -1, 0, 0, -400, 0]

See also:

Projection