PIXI.settings
namespace settings
User's customizable globals for overriding the default PIXI settings, such as a renderer's default resolution, framerate, float precision, etc.
// 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;
Summary
Properties from settings
Public Properties
static ADAPTER: PIXI.IAdapter = PIXI.BrowserAdapter
This adapter is used to call methods that are platform dependent.
For example document.createElement
only runs on the web but fails in node environments.
This allows us to support more platforms by abstracting away specific implementations per platform.
By default the adapter is set to work in the browser. However you can create your own
by implementing the IAdapter
interface. See IAdapter
for more information.
static ANISOTROPIC_LEVEL: number = 0
Default anisotropic filtering level of textures. Usually from 0 to 16
static CAN_UPLOAD_SAME_BUFFER: boolean
Can we upload the same buffer in a single frame?
static CREATE_IMAGE_BITMAP: boolean = false
Enables bitmap creation before image load. This feature is experimental.
static FAIL_IF_MAJOR_PERFORMANCE_CAVEAT: boolean = false
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.
static FILTER_MULTISAMPLE: PIXI.MSAA_QUALITY = PIXI.MSAA_QUALITY.NONE
Default filter samples.
static GC_MAX_CHECK_COUNT: number = 600
Default Garbage Collection maximum check count.
static GC_MODE: PIXI.GC_MODES = PIXI.GC_MODES.AUTO
Default Garbage Collection mode.
static MESH_CANVAS_PADDING: number = 0
Default canvasPadding
for canvas-based Mesh rendering.
static MIPMAP_TEXTURES: PIXI.MIPMAP_MODES = PIXI.MIPMAP_MODES.POW2
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.
static PRECISION_FRAGMENT: PIXI.PRECISION = PIXI.PRECISION.MEDIUM
Default specify float precision in fragment shader. iOS is best set at highp due to https://github.com/pixijs/pixi.js/issues/3742
static PRECISION_VERTEX: PIXI.PRECISION = PIXI.PRECISION.HIGH
Default specify float precision in vertex shader.
static PREFER_ENV: number = PIXI.ENV.WEBGL2
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.
static RENDER_OPTIONS: object
The default render options if none are supplied to PIXI.Renderer or PIXI.CanvasRenderer.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
antialias | boolean |
<optional> |
false | |
autoDensity | boolean |
<optional> |
false | |
backgroundAlpha | number |
<optional> |
1 | |
backgroundColor | number |
<optional> |
0x000000 | |
clearBeforeRender | boolean |
<optional> |
true | |
height | number |
<optional> |
600 | |
legacy | boolean |
<optional> |
false | |
preserveDrawingBuffer | boolean |
<optional> |
false | |
useContextAlpha | boolean |
<optional> |
true | |
view | HTMLCanvasElement |
<optional> |
null | |
width | number |
<optional> |
800 |
static RESOLUTION: number = 1
Default resolution / device pixel ratio of the renderer.
static RETINA_PREFIX: RegExp = /@([0-9\.]+)x/
The prefix that denotes a URL is for a retina asset.
`@2x`
static ROUND_PIXELS: boolean = false
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.
static SCALE_MODE: PIXI.SCALE_MODES = PIXI.SCALE_MODES.LINEAR
Default scale mode for textures.
static SORTABLE_CHILDREN: boolean = false
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.
static SPRITE_BATCH_SIZE: number = 4096
The default sprite batch size.
The default aims to balance desktop and mobile devices.
static SPRITE_MAX_TEXTURES: number = 32
The maximum textures that this device supports.
static STRICT_TEXTURE_CACHE: boolean = false
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.
static UPLOADS_PER_FRAME: number = 4
Default number of uploads per frame using prepare plugin.
static WRAP_MODE: PIXI.WRAP_MODES = PIXI.WRAP_MODES.CLAMP
Default wrap modes that are supported by pixi.