Namespace: settings

PIXI.settings

User's customizable globals for overriding the default PIXI settings, such as a renderer's default resolution, framerate, float precision, etc.

Example


 // Use the native window resolution as the default resolution
 // will support high-density displays when rendering
 PIXI.settings.RESOLUTION = window.devicePixelRatio;

 // Disable interpolation when scaling, will make texture be pixelated
 PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST;

Members

PIXI.settings.ANISOTROPIC_LEVEL number static

Default anisotropic filtering level of textures. Usually from 0 to 16

Default Value:
  • 0

PIXI.settings.CAN_UPLOAD_SAME_BUFFER boolean static

Can we upload the same buffer in a single frame?

PIXI.settings.CREATE_IMAGE_BITMAP boolean static

Enables bitmap creation before image load. This feature is experimental.

Default Value:
  • false

PIXI.settings.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT boolean static

Should the failIfMajorPerformanceCaveat flag be enabled as a context option used in the isWebGLSupported function. If set to true, a WebGL renderer can fail to be created if the browser thinks there could be performance issues when using WebGL.

In PixiJS v6 this has changed from true to false by default, to allow WebGL to work in as many scenarios as possible. However, some users may have a poor experience, for example, if a user has a gpu or driver version blacklisted by the browser.

If your application requires high performance rendering, you may wish to set this to false. We recommend one of two options if you decide to set this flag to false:

1: Use the pixi.js-legacy package, which includes a Canvas renderer as a fallback in case high performance WebGL is not supported.

2: Call isWebGLSupported (which if found in the PIXI.utils package) in your code before attempting to create a PixiJS renderer, and show an error message to the user if the function returns false, explaining that their device & browser combination does not support high performance WebGL. This is a much better strategy than trying to create a PixiJS renderer and finding it then fails.

Default Value:
  • false

PIXI.settings.FILTER_RESOLUTION number static

Default filter resolution.

Default Value:
  • 1

PIXI.settings.GC_MAX_CHECK_COUNT number static

Default Garbage Collection maximum check count.

Default Value:
  • 600

PIXI.settings.GC_MAX_IDLE number static

Default Garbage Collection max idle.

Default Value:
  • 3600

PIXI.settings.GC_MODE PIXI.GC_MODES static

Default Garbage Collection mode.

Default Value:
  • PIXI.GC_MODES.AUTO

PIXI.settings.MESH_CANVAS_PADDING number static

Default canvasPadding for canvas-based Mesh rendering.

Default Value:
  • 0
See:
  • PIXI.Mesh2d#canvasPadding

PIXI.settings.MIPMAP_TEXTURES PIXI.MIPMAP_MODES static

If set to true WebGL will attempt make textures mimpaped by default. Mipmapping will only succeed if the base texture uploaded has power of two dimensions.

Default Value:
  • PIXI.MIPMAP_MODES.POW2

PIXI.settings.PRECISION_FRAGMENT PIXI.PRECISION static

Default specify float precision in fragment shader. iOS is best set at highp due to https://github.com/pixijs/pixi.js/issues/3742

Default Value:
  • PIXI.PRECISION.MEDIUM

PIXI.settings.PRECISION_VERTEX PIXI.PRECISION static

Default specify float precision in vertex shader.

Default Value:
  • PIXI.PRECISION.HIGH

PIXI.settings.PREFER_ENV number static

The maximum support for using WebGL. If a device does not support WebGL version, for instance WebGL 2, it will still attempt to fallback support to WebGL 1. If you want to explicitly remove feature support to target a more stable baseline, prefer a lower environment.

Due to bug in chromium we disable webgl2 by default for all non-apple mobile devices.

Default Value:
  • PIXI.ENV.WEBGL2

PIXI.settings.RENDER_OPTIONS object static

The default render options if none are supplied to PIXI.Renderer or PIXI.CanvasRenderer.

Properties:
Name Type Attributes Value Description
antialias boolean <constant>
false
autoDensity boolean <constant>
false
backgroundAlpha number <constant>
1
backgroundColor number <constant>
0x000000
clearBeforeRender boolean <constant>
true
height number <constant>
600
legacy boolean <constant>
false
preserveDrawingBuffer boolean <constant>
false
useContextAlpha boolean <constant>
true
view HTMLCanvasElement <constant>
null
width number <constant>
800

PIXI.settings.RESOLUTION number static

Default resolution / device pixel ratio of the renderer.

Default Value:
  • 1

PIXI.settings.RETINA_PREFIX RegExp static

The prefix that denotes a URL is for a retina asset.

Default Value:
  • /@([0-9\.]+)x/
Example
`@2x`

PIXI.settings.ROUND_PIXELS boolean static

If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation. Advantages can include sharper image quality (like text) and faster rendering on canvas. The main disadvantage is movement of objects may appear less smooth.

Default Value:
  • false

PIXI.settings.SCALE_MODE PIXI.SCALE_MODES static

Default scale mode for textures.

Default Value:
  • PIXI.SCALE_MODES.LINEAR

PIXI.settings.SORTABLE_CHILDREN boolean static

Sets the default value for the container property 'sortableChildren'. If set to true, the container will sort its children by zIndex value when updateTransform() is called, or manually if sortChildren() is called.

This actually changes the order of elements in the array, so should be treated as a basic solution that is not performant compared to other solutions, such as @link https://github.com/pixijs/pixi-display

Also be aware of that this may not work nicely with the addChildAt() function, as the zIndex sorting may cause the child to automatically sorted to another position.

Default Value:
  • false

PIXI.settings.SPRITE_BATCH_SIZE number static

The default sprite batch size.

The default aims to balance desktop and mobile devices.

Default Value:
  • 4096

PIXI.settings.SPRITE_MAX_TEXTURES number static

The maximum textures that this device supports.

Default Value:
  • 32

PIXI.settings.STRICT_TEXTURE_CACHE boolean static

If set to true, only Textures and BaseTexture objects stored in the caches (TextureCache and BaseTextureCache) can be used when calling Texture.from or BaseTexture.from. Otherwise, these from calls throw an exception. Using this property can be useful if you want to enforce preloading all assets with Loader.

Default Value:
  • false

PIXI.settings.TARGET_FPMS number static

Target frames per millisecond.

Default Value:
  • 0.06

PIXI.settings.UPLOADS_PER_FRAME number static

Default number of uploads per frame using prepare plugin.

Default Value:
  • 4

PIXI.settings.WRAP_MODE PIXI.WRAP_MODES static

Default wrap modes that are supported by pixi.

Default Value:
  • PIXI.WRAP_MODES.CLAMP