/** * An Application represents and manages your PlayCanvas application. If you are developing using * the PlayCanvas Editor, the Application is created for you. You can access your Application * instance in your scripts. Below is a skeleton script which shows how you can access the * application 'app' property inside the initialize and update functions: * * ```javascript * // Editor example: accessing the pc.Application from a script * var MyScript = pc.createScript('myScript'); * * MyScript.prototype.initialize = function() { * // Every script instance has a property 'this.app' accessible in the initialize... * const app = this.app; * }; * * MyScript.prototype.update = function(dt) { * // ...and update functions. * const app = this.app; * }; * ``` * * If you are using the Engine without the Editor, you have to create the application instance * manually. */ export class Application extends AppBase { /** * Create a new Application instance. * * Automatically registers these component systems with the application's component system registry: * * - anim ({@link AnimComponentSystem}) * - animation ({@link AnimationComponentSystem}) * - audiolistener ({@link AudioListenerComponentSystem}) * - button ({@link ButtonComponentSystem}) * - camera ({@link CameraComponentSystem}) * - collision ({@link CollisionComponentSystem}) * - element ({@link ElementComponentSystem}) * - layoutchild ({@link LayoutChildComponentSystem}) * - layoutgroup ({@link LayoutGroupComponentSystem}) * - light ({@link LightComponentSystem}) * - model ({@link ModelComponentSystem}) * - particlesystem ({@link ParticleSystemComponentSystem}) * - rigidbody ({@link RigidBodyComponentSystem}) * - render ({@link RenderComponentSystem}) * - screen ({@link ScreenComponentSystem}) * - script ({@link ScriptComponentSystem}) * - scrollbar ({@link ScrollbarComponentSystem}) * - scrollview ({@link ScrollViewComponentSystem}) * - sound ({@link SoundComponentSystem}) * - sprite ({@link SpriteComponentSystem}) * * @param {HTMLCanvasElement | OffscreenCanvas} canvas - The canvas element. * @param {object} [options] - The options object to configure the Application. * @param {import('./input/element-input.js').ElementInput} [options.elementInput] - Input * handler for {@link ElementComponent}s. * @param {import('../platform/input/keyboard.js').Keyboard} [options.keyboard] - Keyboard * handler for input. * @param {import('../platform/input/mouse.js').Mouse} [options.mouse] - Mouse handler for * input. * @param {import('../platform/input/touch-device.js').TouchDevice} [options.touch] - TouchDevice * handler for input. * @param {import('../platform/input/game-pads.js').GamePads} [options.gamepads] - Gamepad * handler for input. * @param {string} [options.scriptPrefix] - Prefix to apply to script urls before loading. * @param {string} [options.assetPrefix] - Prefix to apply to asset urls before loading. * @param {import('../platform/graphics/graphics-device.js').GraphicsDevice} [options.graphicsDevice] - The * graphics device used by the application. If not provided, a WebGl graphics device will be * created. * @param {object} [options.graphicsDeviceOptions] - Options object that is passed into the * {@link GraphicsDevice} constructor. * @param {string[]} [options.scriptsOrder] - Scripts in order of loading first. * @example * // Engine-only example: create the application manually * const app = new pc.Application(canvas, options); * * // Start the application's main loop * app.start(); */ constructor(canvas: HTMLCanvasElement | OffscreenCanvas, options?: { elementInput?: import("./input/element-input.js").ElementInput; keyboard?: import("../platform/input/keyboard.js").Keyboard; mouse?: import("../platform/input/mouse.js").Mouse; touch?: import("../platform/input/touch-device.js").TouchDevice; gamepads?: import("../platform/input/game-pads.js").GamePads; scriptPrefix?: string; assetPrefix?: string; graphicsDevice?: import("../platform/graphics/graphics-device.js").GraphicsDevice; graphicsDeviceOptions?: object; scriptsOrder?: string[]; }); createDevice(canvas: any, options: any): WebglGraphicsDevice; addComponentSystems(appOptions: any): void; addResourceHandles(appOptions: any): void; } import { AppBase } from './app-base.js'; import { WebglGraphicsDevice } from '../platform/graphics/webgl/webgl-graphics-device.js';