Skip to Content
🎉 @playcanvas/react 0.3.0! Now with React 19 support. Read more →
DocsAPIApplication

Application

The Application is the root component for any PlayCanvas React application. It initializes and manages the canvas and PlayCanvas application instance.

Usage

The Application component wraps all other components.

import { Application, Entity } from '@playcanvas/react' import { Camera } from '@playcanvas/react/components' import { OrbitControls } from '@playcanvas/react/scripts' export default function Scene() { return ( <Application fillMode={FILLMODE_FILL_WINDOW} resolutionMode={RESOLUTION_AUTO} > <Entity name="camera" position={[0, 0, 10]}> <Camera /> <OrbitControls /> </Entity> {/* Your scene content */} </Application> ) }

Props

NameTypeDefault
fillModestring

Controls how the canvas fills the window and resizes when the window changes.

FILLMODE_NONE
resolutionModestring

Change the resolution of the canvas, and set the way it behaves when the window is resized.

RESOLUTION_AUTO
usePhysicsboolean

When true, the PlayCanvas Physics system will be enabled.

false
graphicsDeviceOptionsPartial<PublicProps<GraphicsDevice>>

Graphics Settings

childrenReactNode

The children of the application

enableBundlesboolean

Set this to false if you want to run without using bundles. We set it to true only if TextDecoder is available because we currently rely on it for untarring.

frameRequestIdany

A request id returned by requestAnimationFrame, allowing us to cancel it.

timeScalenumber

Scales the global time delta. Defaults to 1.

maxDeltaTimenumber

Clamps per-frame delta time to an upper bound. Useful since returning from a tab deactivation can generate huge values for dt, which can adversely affect game state. Defaults to 0.1 (seconds).

framenumber

The total number of frames the application has updated since start() was called.

frameGraphFrameGraph

The frame graph.

rendererForwardRenderer

The forward renderer.

scriptsOrderstring[]

Scripts in order of loading first.

statsApplicationStats

The application’s performance stats.

autoRenderboolean

When true, the application’s render function is called every frame. Setting autoRender to false is useful to applications where the rendered image may often be unchanged over time. This can heavily reduce the application’s load on the CPU and GPU. Defaults to true.

renderNextFrameboolean

Set to true to render the scene on the next iteration of the main loop. This only has an effect if AppBase#autoRender is set to false. The value of renderNextFrame is set back to false again as soon as the scene has been rendered.

graphicsDeviceGraphicsDevice

The graphics device used by the application.

rootEntity

The root entity of the application.

sceneScene

The scene managed by the application.

lightmapperLightmapper | null

The run-time lightmapper.

loaderResourceLoader

The resource loader.

assetsAssetRegistry

The asset registry managed by the application.

bundlesBundleRegistry

The bundle registry managed by the application.

scenesSceneRegistry

The scene registry managed by the application.

scriptsScriptRegistry

The application’s script registry.

systemsComponentSystemRegistry

The application’s component system registry.

i18nI18n

Handles localization.

keyboardKeyboard | null

The keyboard device.

mouseMouse | null

The mouse device.

touchTouchDevice | null

Used to get touch events input.

gamepadsGamePads | null

Used to access GamePad input.

elementInputElementInput | null

Used to handle input for ElementComponents.

xrXrManager | null

The XR Manager that provides ability to start VR/AR sessions.

defaultLayerWorldLayer
defaultLayerDepthLayer
defaultLayerSkyboxLayer
defaultLayerUiLayer
defaultLayerImmediateLayer
controllerany
contextany
classNamestring

The class name to attach to the canvas component

pc-app
styleRecord<string, unknown>

A style object added to the canvas component

{ width: '100%', height: '100%' }

usePhysics

Enables physics for the application. Learn more about Physics in Playcanvas . Entities will need to have a RigidBody and Collisions components to be affected by physics.

Type: boolean Default: false

fillMode

This prop determines how the canvas fills its container. It accepts one of the following values from PlayCanvas:

  • FILLMODE_NONE - The canvas will be the size specified by the width and height props
  • FILLMODE_FILL_WINDOW - The canvas will fill the browser window
  • FILLMODE_KEEP_ASPECT - The canvas will maintain its aspect ratio while filling the container

Default: FILLMODE_NONE

resolutionMode

The resolutionMode prop determines how the canvas resolution is set. It accepts one of the following values from PlayCanvas:

  • RESOLUTION_AUTO - The resolution will be automatically adjusted based on the device’s pixel ratio
  • RESOLUTION_FIXED - The resolution will be fixed at the specified width and height
  • RESOLUTION_NATIVE - The resolution will match the device’s native resolution

Default: RESOLUTION_AUTO

width

The width prop specifies the width of the canvas when using RESOLUTION_FIXED.

height

The height prop specifies the height of the canvas when using RESOLUTION_FIXED.

Last updated on