<Application/>
<Application /> は PlayCanvas React アプリケーションのルートです。エンジンを初期化し、レンダリングコンテキストを提供します。Application はアプリ内の単一のキャンバスに対応します。
フィルモードと解像度モードを設定してキャンバスのウィンドウへのフィット方法を制御し、その他のプロパティでグラフィックスデバイスを制御できます。
import { Application } from '@playcanvas/react'
export default function Scene() {
return (
<Application
fillMode={FILLMODE_FILL_WINDOW}
resolutionMode={RESOLUTION_AUTO}
>
{/* シーンのコンテンツ */}
</Application>
)
}
プロパティ
| Name | Type | Default |
|---|---|---|
fillMode? | "NONE" | "FILL_WINDOW" | "KEEP_ASPECT"Controls how the canvas fills the window and resizes when the window changes. | FILLMODE_NONE |
resolutionMode? | "AUTO" | "FIXED"Change the resolution of the canvas, and set the way it behaves when the window is resized. | RESOLUTION_AUTO |
usePhysics? | booleanWhen `true`, the PlayCanvas Physics system will be enabled. | false |
deviceTypes? | DeviceType[]The device types to use for the graphics device. This allows you to set an order of preference for the graphics device.
The first device type in the array that is supported by the browser will be used. | [DEVICETYPE_WEBGL2] |
graphicsDeviceOptions? | GraphicsDeviceOptionsGraphics Settings | - |
children? | ReactNodeThe children of the application | - |
timeScale? | numberScales the global time delta. Defaults to 1. | - |
maxDeltaTime? | numberClamps 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). | - |
scriptsOrder? | string[]Scripts in order of loading first. | - |
autoRender? | booleanWhen 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. | - |
renderNextFrame? | booleanSet to true to render the scene on the next iteration of the main loop. This only has an
effect if autoRender is set to false. The value of renderNextFrame is set back to
false again as soon as the scene has been rendered. | - |
graphicsDevice? | GraphicsDeviceThe graphics device used by the application. | - |
root? | EntityThe root entity of the application. | - |
lightmapper? | Lightmapper | nullThe run-time lightmapper. | - |
loader? | ResourceLoaderThe resource loader. | - |
scenes? | SceneRegistryThe scene registry managed by the application. | - |
systems? | ComponentSystemRegistryThe application's component system registry. | - |
i18n? | I18nHandles localization. | - |
elementInput? | ElementInput | nullUsed to handle input for ElementComponents. | - |
xr? | XrManager | nullThe XR Manager that provides ability to start VR/AR sessions. | - |
defaultLayerWorld? | - | |
defaultLayerDepth? | - | |
defaultLayerSkybox? | - | |
defaultLayerUi? | - | |
defaultLayerImmediate? | - | |
controller? | any | - |
context? | any | - |
className? | stringThe class name to attach to the canvas component | pc-app |
style? | Record<string, unknown>A style object added to the canvas component | { width: '100%', height: '100%' } |