---
title: "perspective | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Function perspective

-   perspective(  
        out: [mat4](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.mat4/),  
        fovy: number,  
        aspect: number,  
        near: number,  
        far: number,  
    ): [mat4](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.mat4/)[](#perspective)
    
    Generates a perspective projection matrix with the given bounds. The near/far clip planes correspond to a normalized device coordinate Z range of \[-1, 1\], which matches WebGL/OpenGL's clip volume. Passing null/undefined/no value for far will generate infinite projection matrix.
    
    #### Parameters
    
    -   out: [mat4](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.mat4/)
        
        mat4 frustum matrix will be written into
        
    -   fovy: number
        
        Vertical field of view in radians
        
    -   aspect: number
        
        Aspect ratio. typically viewport width/height
        
    -   near: number
        
        Near bound of the frustum
        
    -   far: number
        
        Far bound of the frustum, can be null or Infinity
        
    
    #### Returns [mat4](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.mat4/)
    
    out
