Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed AppCreateOptions to AppOptions #4178

Merged
merged 1 commit into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions src/framework/app-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ import {
/** @typedef {import('../scene/mesh-instance.js').MeshInstance} MeshInstance */
/** @typedef {import('../scene/lightmapper/lightmapper.js').Lightmapper} Lightmapper */
/** @typedef {import('../scene/batching/batch-manager.js').BatchManager} BatchManager */
/** @typedef {import('../framework/app-create-options.js').AppCreateOptions} AppCreateOptions */
/** @typedef {import('./app-options.js').AppOptions} AppOptions */
/** @typedef {import('../xr/xr-manager.js').XrManager} XrManager */
/** @typedef {import('../sound/manager.js').SoundManager} SoundManager */

Expand Down Expand Up @@ -143,9 +143,9 @@ class AppBase extends EventHandler {
* @param {Element} canvas - The canvas element.
* @example
* // Engine-only example: create the application manually
* var createOptions = new AppCreateOptions();
* var options = new AppOptions();
* var app = new pc.AppBase(canvas);
* app.init(createOptions);
* app.init(options);
*
* // Start the application's main loop
* app.start();
Expand Down Expand Up @@ -261,15 +261,15 @@ class AppBase extends EventHandler {
/**
* Initialize the app.
*
* @param {AppCreateOptions} createOptions - Options specifying the init parameters for the app.
* @param {AppOptions} appOptions - Options specifying the init parameters for the app.
*/
init(createOptions) {
init(appOptions) {
/**
* The graphics device used by the application.
*
* @type {GraphicsDevice}
*/
this.graphicsDevice = createOptions.graphicsDevice;
this.graphicsDevice = appOptions.graphicsDevice;
Debug.assert(this.graphicsDevice, "The application cannot be created without a valid GraphicsDevice");

this._initDefaultMaterial();
Expand All @@ -279,7 +279,7 @@ class AppBase extends EventHandler {
* @type {SoundManager}
* @private
*/
this._soundManager = createOptions.soundManager;
this._soundManager = appOptions.soundManager;

/**
* The resource loader.
Expand Down Expand Up @@ -329,7 +329,7 @@ class AppBase extends EventHandler {
* var vehicleAssets = this.app.assets.findByTag('vehicle');
*/
this.assets = new AssetRegistry(this.loader);
if (createOptions.assetPrefix) this.assets.prefix = createOptions.assetPrefix;
if (appOptions.assetPrefix) this.assets.prefix = appOptions.assetPrefix;

/**
* @type {BundleRegistry}
Expand All @@ -346,7 +346,7 @@ class AppBase extends EventHandler {
*/
this.enableBundles = (typeof TextDecoder !== 'undefined');

this.scriptsOrder = createOptions.scriptsOrder || [];
this.scriptsOrder = appOptions.scriptsOrder || [];

/**
* The application's script registry.
Expand Down Expand Up @@ -453,8 +453,8 @@ class AppBase extends EventHandler {
* @type {Lightmapper}
*/
this.lightmapper = null;
if (createOptions.lightmapper) {
this.lightmapper = new createOptions.lightmapper(this.graphicsDevice, this.root, this.scene, this.renderer, this.assets);
if (appOptions.lightmapper) {
this.lightmapper = new appOptions.lightmapper(this.graphicsDevice, this.root, this.scene, this.renderer, this.assets);
this.once('prerender', this._firstBake, this);
}

Expand All @@ -464,8 +464,8 @@ class AppBase extends EventHandler {
* @type {BatchManager}
*/
this._batcher = null;
if (createOptions.batchManager) {
this._batcher = new createOptions.batchManager(this.graphicsDevice, this.root, this.scene);
if (appOptions.batchManager) {
this._batcher = new appOptions.batchManager(this.graphicsDevice, this.root, this.scene);
this.once('prerender', this._firstBatch, this);
}

Expand All @@ -474,35 +474,35 @@ class AppBase extends EventHandler {
*
* @type {Keyboard}
*/
this.keyboard = createOptions.keyboard || null;
this.keyboard = appOptions.keyboard || null;

/**
* The mouse device.
*
* @type {Mouse}
*/
this.mouse = createOptions.mouse || null;
this.mouse = appOptions.mouse || null;

/**
* Used to get touch events input.
*
* @type {TouchDevice}
*/
this.touch = createOptions.touch || null;
this.touch = appOptions.touch || null;

/**
* Used to access GamePad input.
*
* @type {GamePads}
*/
this.gamepads = createOptions.gamepads || null;
this.gamepads = appOptions.gamepads || null;

/**
* Used to handle input for {@link ElementComponent}s.
*
* @type {ElementInput}
*/
this.elementInput = createOptions.elementInput || null;
this.elementInput = appOptions.elementInput || null;
if (this.elementInput)
this.elementInput.app = this;

Expand All @@ -516,7 +516,7 @@ class AppBase extends EventHandler {
* // VR is available
* }
*/
this.xr = new createOptions.xr(this);
this.xr = new appOptions.xr(this);

if (this.elementInput)
this.elementInput.attachSelectEvents();
Expand All @@ -537,14 +537,14 @@ class AppBase extends EventHandler {
* @type {string}
* @ignore
*/
this._scriptPrefix = createOptions.scriptPrefix || '';
this._scriptPrefix = appOptions.scriptPrefix || '';

if (this.enableBundles) {
this.loader.addHandler("bundle", new BundleHandler(this));
}

// create and register all required resource handlers
createOptions.resourceHandlers.forEach((resourceHandler) => {
appOptions.resourceHandlers.forEach((resourceHandler) => {
const handler = new resourceHandler(this);
this.loader.addHandler(handler.handlerType, handler);
});
Expand Down Expand Up @@ -585,7 +585,7 @@ class AppBase extends EventHandler {
this.systems = new ComponentSystemRegistry();

// create and register all required component systems
createOptions.componentSystems.forEach((componentSystem) => {
appOptions.componentSystems.forEach((componentSystem) => {
this.systems.add(new componentSystem(this));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/** @typedef {import('./components/system.js').ComponentSystem} ComponentSystem */
/** @typedef {import('../xr/xr-manager.js').XrManager} XrManager */

class AppCreateOptions {
class AppOptions {
/**
* Input handler for {@link ElementComponent}s.
*
Expand Down Expand Up @@ -118,4 +118,4 @@ class AppCreateOptions {
resourceHandlers = [];
}

export { AppCreateOptions };
export { AppOptions };
44 changes: 22 additions & 22 deletions src/framework/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Lightmapper } from '../scene/lightmapper/lightmapper.js';
import { BatchManager } from '../scene/batching/batch-manager.js';

import { AppBase } from './app-base.js';
import { AppCreateOptions } from './app-create-options.js';
import { AppOptions } from './app-options.js';
import { script } from './script.js';
import { AnimationComponentSystem } from './components/animation/system.js';
import { AnimComponentSystem } from './components/anim/system.js';
Expand Down Expand Up @@ -119,28 +119,28 @@ import { XrManager } from '../xr/xr-manager.js';
constructor(canvas, options = {}) {
super(canvas);

const createOptions = new AppCreateOptions();
const appOptions = new AppOptions();

createOptions.graphicsDevice = this.createDevice(canvas, options);
this.addComponentSystems(createOptions);
this.addResourceHandles(createOptions);
appOptions.graphicsDevice = this.createDevice(canvas, options);
this.addComponentSystems(appOptions);
this.addResourceHandles(appOptions);

createOptions.elementInput = options.elementInput;
createOptions.keyboard = options.keyboard;
createOptions.mouse = options.mouse;
createOptions.touch = options.touch;
createOptions.gamepads = options.gamepads;
appOptions.elementInput = options.elementInput;
appOptions.keyboard = options.keyboard;
appOptions.mouse = options.mouse;
appOptions.touch = options.touch;
appOptions.gamepads = options.gamepads;

createOptions.scriptPrefix = options.scriptPrefix;
createOptions.assetPrefix = options.assetPrefix;
createOptions.scriptsOrder = options.scriptsOrder;
appOptions.scriptPrefix = options.scriptPrefix;
appOptions.assetPrefix = options.assetPrefix;
appOptions.scriptsOrder = options.scriptsOrder;

createOptions.soundManager = new SoundManager(options);
createOptions.lightmapper = Lightmapper;
createOptions.batchManager = BatchManager;
createOptions.xr = XrManager;
appOptions.soundManager = new SoundManager(options);
appOptions.lightmapper = Lightmapper;
appOptions.batchManager = BatchManager;
appOptions.xr = XrManager;

this.init(createOptions);
this.init(appOptions);
}

createDevice(canvas, options) {
Expand All @@ -156,8 +156,8 @@ import { XrManager } from '../xr/xr-manager.js';
return new WebglGraphicsDevice(canvas, options.graphicsDeviceOptions);
}

addComponentSystems(createOptions) {
createOptions.componentSystems = [
addComponentSystems(appOptions) {
appOptions.componentSystems = [
RigidBodyComponentSystem,
CollisionComponentSystem,
JointComponentSystem,
Expand All @@ -184,8 +184,8 @@ import { XrManager } from '../xr/xr-manager.js';
];
}

addResourceHandles(createOptions) {
createOptions.resourceHandlers = [
addResourceHandles(appOptions) {
appOptions.resourceHandlers = [
RenderHandler,
AnimationHandler,
AnimClipHandler,
Expand Down