Skip to content

Commit

Permalink
[REFACTOR] Move Pixi's settings to a special file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jomshir98 committed Oct 11, 2023
1 parent d305eb7 commit 7e6e97c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
5 changes: 1 addition & 4 deletions pandora-client-web/src/assets/graphicsLoader.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { Assert, GetLogger, Logger } from 'pandora-common';
import { BaseTexture, IImageResourceOptions, Resource, Texture, autoDetectResource, settings as PIXISettings } from 'pixi.js';
import { BaseTexture, IImageResourceOptions, Resource, Texture, autoDetectResource } from 'pixi.js';
import { PersistentToast } from '../persistentToast';
import { IGraphicsLoader } from './graphicsManager';

// Prevent PIXI from doing PIXI things
PIXISettings.STRICT_TEXTURE_CACHE = true;

/**
* Interval after which texture load is retried, if the texture is still being requested.
* Last interval is repeated indefinitely until the load either succeeds or the texture is no longer needed.
Expand Down
2 changes: 2 additions & 0 deletions pandora-client-web/src/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { GraphicsManager } from '../assets/graphicsManager';
import { EulaGate } from '../components/Eula';
import { EditorWardrobeContextProvider } from './components/wardrobe/wardrobe';
import { AssetManagerEditor } from './assets/assetManager';
import { ConfigurePixiSettings } from '../graphics/pixiSettings';

const logger = GetLogger('init');

Expand All @@ -27,6 +28,7 @@ Start().catch((error) => {
*/
async function Start(): Promise<void> {
SetupLogging();
ConfigurePixiSettings();
logger.info('Starting...');
createRoot(document.querySelector('#editor-root') as HTMLElement).render(
<React.StrictMode>
Expand Down
9 changes: 9 additions & 0 deletions pandora-client-web/src/graphics/pixiSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { settings as PIXISettings } from 'pixi.js';

/**
* This function applies global Pixi.js settings we need
*/
export function ConfigurePixiSettings(): void {
// Prevent PIXI from caching remote textures itself (we have our own cache management)
PIXISettings.STRICT_TEXTURE_CACHE = true;
}
2 changes: 2 additions & 0 deletions pandora-client-web/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import './styles/globalUtils.scss';
import { PandoraRoutes } from './routing/Routes';
import { Dialogs } from './components/dialog/dialog';
import { HoverElementsPortal } from './components/hoverElement/hoverElement';
import { ConfigurePixiSettings } from './graphics/pixiSettings';

const logger = GetLogger('init');

Expand All @@ -27,6 +28,7 @@ try {
*/
function Start(): void {
SetupLogging();
ConfigurePixiSettings();
logger.info('Starting...');
logger.verbose('Build mode:', (NODE_ENV === 'production' && USER_DEBUG) ? 'userdebug' : NODE_ENV);
createRoot(document.querySelector('#pandora-root') as HTMLElement).render(
Expand Down

0 comments on commit 7e6e97c

Please sign in to comment.