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

ResourceHandler type fix (constructor parameters) #6063

Merged
merged 1 commit into from
Feb 19, 2024
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
5 changes: 3 additions & 2 deletions src/framework/handlers/anim-clip.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import { ResourceHandler } from './handler.js';
* @ignore
*/
class AnimClipHandler extends ResourceHandler {
constructor() {
super('animclip');
constructor(app) {
super(app);
this.handlerType = 'animclip';
Comment on lines +16 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not make the super constructor accept two parameters: app, and the handlerType?
so that this would be super(app, 'animclip');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that might have caused a constructor type clash but it apparently does not so Ive modified it with this change 👍

}

load(url, callback) {
Expand Down
5 changes: 3 additions & 2 deletions src/framework/handlers/anim-state-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import { ResourceHandler } from './handler.js';
* @ignore
*/
class AnimStateGraphHandler extends ResourceHandler {
constructor() {
super('animstategraph');
constructor(app) {
super(app);
this.handlerType = 'animstategraph';
}

load(url, callback) {
Expand Down
3 changes: 2 additions & 1 deletion src/framework/handlers/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class AnimationHandler extends ResourceHandler {
* @ignore
*/
constructor(app) {
super('animation');
super(app);
this.handlerType = 'animation';

this.device = app.graphicsDevice;
this.assets = app.assets;
Expand Down
3 changes: 2 additions & 1 deletion src/framework/handlers/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class AudioHandler extends ResourceHandler {
* @ignore
*/
constructor(app) {
super('audio');
super(app);
this.handlerType = 'audio';

this.manager = app.soundManager;
Debug.assert(this.manager, "AudioSourceComponentSystem cannot be created without sound manager");
Expand Down
5 changes: 3 additions & 2 deletions src/framework/handlers/binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { http, Http } from '../../platform/net/http.js';
import { ResourceHandler } from './handler.js';

class BinaryHandler extends ResourceHandler {
constructor() {
super('binary');
constructor(app) {
super(app);
this.handlerType = 'binary';
}

load(url, callback) {
Expand Down
3 changes: 2 additions & 1 deletion src/framework/handlers/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class BundleHandler extends ResourceHandler {
* @param {import('../app-base.js').AppBase} app - The running {@link AppBase}.
*/
constructor(app) {
super('bundle');
super(app);
this.handlerType = 'bundle';

this._assets = app.assets;
this._worker = null;
Expand Down
3 changes: 2 additions & 1 deletion src/framework/handlers/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ class ContainerHandler extends ResourceHandler {
* @ignore
*/
constructor(app) {
super('container');
super(app);
this.handlerType = 'container';

this.glbContainerParser = new GlbContainerParser(app.graphicsDevice, app.assets, 0);
this.parsers = { };
Expand Down
5 changes: 3 additions & 2 deletions src/framework/handlers/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { http } from '../../platform/net/http.js';
import { ResourceHandler } from './handler.js';

class CssHandler extends ResourceHandler {
constructor() {
super('css');
constructor(app) {
super(app);
this.handlerType = 'css';
}

load(url, callback) {
Expand Down
3 changes: 2 additions & 1 deletion src/framework/handlers/cubemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class CubemapHandler extends ResourceHandler {
* @ignore
*/
constructor(app) {
super('cubemap');
super(app);
this.handlerType = 'cubemap';

this._device = app.graphicsDevice;
this._registry = app.assets;
Expand Down
5 changes: 3 additions & 2 deletions src/framework/handlers/folder.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ResourceHandler } from './handler.js';

class FolderHandler extends ResourceHandler {
constructor() {
super('folder');
constructor(app) {
super(app);
this.handlerType = 'folder';
}

load(url, callback) {
Expand Down
3 changes: 2 additions & 1 deletion src/framework/handlers/font.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class FontHandler extends ResourceHandler {
* @ignore
*/
constructor(app) {
super('font');
super(app);
this.handlerType = 'font';

this._loader = app.loader;
this.maxRetries = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/framework/handlers/gsplat.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class GSplatHandler extends ResourceHandler {
* @hideconstructor
*/
constructor(app) {
super('gsplat');
super(app);
this.handlerType = 'gsplat';
this.parser = new PlyParser(app.graphicsDevice, app.assets, 3);
}

Expand Down
15 changes: 11 additions & 4 deletions src/framework/handlers/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,23 @@ class ResourceHandler {
*
* @type {string}
*/
handlerType;
handlerType = '';

/**
* The running app instance.
*
* @type {import('../app-base').AppBase}
*/
_app;

/** @private */
_maxRetries = 0;

/**
* @param {string} type - The type of resource the handler will load.
* @param {import('../app-base').AppBase} app - The running {@link AppBase}.
*/
constructor(type) {
this.handlerType = type;
constructor(app) {
this._app = app;
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/framework/handlers/hierarchy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { SceneUtils } from './scene-utils.js';
import { ResourceHandler } from './handler.js';

class HierarchyHandler extends ResourceHandler {
/**
* @param {import('../app-base').AppBase} app - The running {@link AppBase}.
*/
constructor(app) {
super('hierarchy');

this._app = app;
super(app);
this.handlerType = 'hierarchy';
}

load(url, callback) {
Expand Down
5 changes: 3 additions & 2 deletions src/framework/handlers/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { http } from '../../platform/net/http.js';
import { ResourceHandler } from './handler.js';

class HtmlHandler extends ResourceHandler {
constructor() {
super('html');
constructor(app) {
super(app);
this.handlerType = 'html';
}

load(url, callback) {
Expand Down
5 changes: 3 additions & 2 deletions src/framework/handlers/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { http, Http } from '../../platform/net/http.js';
import { ResourceHandler } from './handler.js';

class JsonHandler extends ResourceHandler {
constructor() {
super('json');
constructor(app) {
super(app);
this.handlerType = 'json';
}

load(url, callback) {
Expand Down
3 changes: 2 additions & 1 deletion src/framework/handlers/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class MaterialHandler extends ResourceHandler {
* @ignore
*/
constructor(app) {
super('material');
super(app);
this.handlerType = 'material';

this._assets = app.assets;
this._device = app.graphicsDevice;
Expand Down
3 changes: 2 additions & 1 deletion src/framework/handlers/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class ModelHandler extends ResourceHandler {
* @ignore
*/
constructor(app) {
super('model');
super(app);
this.handlerType = 'model';

this._parsers = [];
this.device = app.graphicsDevice;
Expand Down
3 changes: 2 additions & 1 deletion src/framework/handlers/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class RenderHandler extends ResourceHandler {
* @ignore
*/
constructor(app) {
super('render');
super(app);
this.handlerType = 'render';

this._registry = app.assets;
}
Expand Down
5 changes: 2 additions & 3 deletions src/framework/handlers/scene-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { ResourceHandler } from './handler.js';

class SceneSettingsHandler extends ResourceHandler {
constructor(app) {
super('scenesettings');

this._app = app;
super(app);
this.handlerType = 'scenesettings';
}

load(url, callback) {
Expand Down
5 changes: 2 additions & 3 deletions src/framework/handlers/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ class SceneHandler extends ResourceHandler {
* @ignore
*/
constructor(app) {
super('scene');

this._app = app;
super(app);
this.handlerType = 'scene';
}

load(url, callback) {
Expand Down
4 changes: 2 additions & 2 deletions src/framework/handlers/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class ScriptHandler extends ResourceHandler {
* @ignore
*/
constructor(app) {
super('script');
super(app);
this.handlerType = 'script';

this._app = app;
this._scripts = { };
this._cache = { };
}
Expand Down
5 changes: 3 additions & 2 deletions src/framework/handlers/shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { http } from '../../platform/net/http.js';
import { ResourceHandler } from './handler.js';

class ShaderHandler extends ResourceHandler {
constructor() {
super('shader');
constructor(app) {
super(app);
this.handlerType = 'shader';
}

load(url, callback) {
Expand Down
3 changes: 2 additions & 1 deletion src/framework/handlers/sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class SpriteHandler extends ResourceHandler {
* @ignore
*/
constructor(app) {
super('sprite');
super(app);
this.handlerType = 'sprite';

this._assets = app.assets;
this._device = app.graphicsDevice;
Expand Down
5 changes: 2 additions & 3 deletions src/framework/handlers/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import { ResourceHandler } from './handler.js';

class TemplateHandler extends ResourceHandler {
constructor(app) {
super('template');

this._app = app;
super(app);
this.handlerType = 'template';
}

load(url, callback) {
Expand Down
3 changes: 2 additions & 1 deletion src/framework/handlers/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { ResourceHandler } from './handler.js';

class TextHandler extends ResourceHandler {
constructor(app) {
super('text');
super(app);
this.handlerType = 'text';
}

load(url, callback) {
Expand Down
3 changes: 2 additions & 1 deletion src/framework/handlers/texture-atlas.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class TextureAtlasHandler extends ResourceHandler {
* @ignore
*/
constructor(app) {
super('textureatlas');
super(app);
this.handlerType = 'textureatlas';

this._loader = app.loader;
}
Expand Down
3 changes: 2 additions & 1 deletion src/framework/handlers/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ class TextureHandler extends ResourceHandler {
* @ignore
*/
constructor(app) {
super('texture');
super(app);
this.handlerType = 'texture';

const assets = app.assets;
const device = app.graphicsDevice;
Expand Down