mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-23 08:00:51 +01:00
Finish fixing imports
This commit is contained in:
parent
b46fe6fcd6
commit
6f04f28261
@ -8,6 +8,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pixi/canvas-renderer": "^6.1.0",
|
"@pixi/canvas-renderer": "^6.1.0",
|
||||||
|
"@pixi/extract": "^6.1.0",
|
||||||
"@pixi/filter-adjustment": "^4.1.3",
|
"@pixi/filter-adjustment": "^4.1.3",
|
||||||
"events": "^3.3.0",
|
"events": "^3.3.0",
|
||||||
"pako": "^2.0.4",
|
"pako": "^2.0.4",
|
||||||
|
@ -25,6 +25,7 @@ import { GameMessageHandler } from './game/GameMessageHandler';
|
|||||||
import { INitro } from './INitro';
|
import { INitro } from './INitro';
|
||||||
import { INitroLocalizationManager } from './localization/INitroLocalizationManager';
|
import { INitroLocalizationManager } from './localization/INitroLocalizationManager';
|
||||||
import { NitroLocalizationManager } from './localization/NitroLocalizationManager';
|
import { NitroLocalizationManager } from './localization/NitroLocalizationManager';
|
||||||
|
import './Plugins';
|
||||||
import { RoomEngineEvent } from './room/events/RoomEngineEvent';
|
import { RoomEngineEvent } from './room/events/RoomEngineEvent';
|
||||||
import { IRoomEngine } from './room/IRoomEngine';
|
import { IRoomEngine } from './room/IRoomEngine';
|
||||||
import { RoomEngine } from './room/RoomEngine';
|
import { RoomEngine } from './room/RoomEngine';
|
||||||
@ -45,7 +46,7 @@ export class Nitro extends Application implements INitro
|
|||||||
public static WEBGL_CONTEXT_LOST: string = 'NE_WEBGL_CONTEXT_LOST';
|
public static WEBGL_CONTEXT_LOST: string = 'NE_WEBGL_CONTEXT_LOST';
|
||||||
public static WEBGL_UNAVAILABLE: string = 'NE_WEBGL_UNAVAILABLE';
|
public static WEBGL_UNAVAILABLE: string = 'NE_WEBGL_UNAVAILABLE';
|
||||||
public static RELEASE_VERSION: string = 'NITRO-2-0-0';
|
public static RELEASE_VERSION: string = 'NITRO-2-0-0';
|
||||||
public static READY: string = 'NE_READY';
|
public static READY: string = 'NE_READY!';
|
||||||
|
|
||||||
private static INSTANCE: INitro = null;
|
private static INSTANCE: INitro = null;
|
||||||
|
|
||||||
|
30
src/nitro/Plugins.ts
Normal file
30
src/nitro/Plugins.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { AccessibilityManager } from '@pixi/accessibility';
|
||||||
|
import { Application } from '@pixi/app';
|
||||||
|
import { CompressedTextureLoader, DDSLoader, KTXLoader } from '@pixi/compressed-textures';
|
||||||
|
import { BatchRenderer, Renderer } from '@pixi/core';
|
||||||
|
import { Extract } from '@pixi/extract';
|
||||||
|
import { InteractionManager } from '@pixi/interaction';
|
||||||
|
import { AppLoaderPlugin, Loader } from '@pixi/loaders';
|
||||||
|
import { ParticleRenderer } from '@pixi/particle-container';
|
||||||
|
import { Prepare } from '@pixi/prepare';
|
||||||
|
import { TilingSpriteRenderer } from '@pixi/sprite-tiling';
|
||||||
|
import { SpritesheetLoader } from '@pixi/spritesheet';
|
||||||
|
import { BitmapFontLoader } from '@pixi/text-bitmap';
|
||||||
|
import { TickerPlugin } from '@pixi/ticker';
|
||||||
|
|
||||||
|
Renderer.registerPlugin('accessibility', AccessibilityManager);
|
||||||
|
Renderer.registerPlugin('extract', Extract);
|
||||||
|
Renderer.registerPlugin('interaction', InteractionManager);
|
||||||
|
Renderer.registerPlugin('particle', ParticleRenderer);
|
||||||
|
Renderer.registerPlugin('prepare', Prepare);
|
||||||
|
Renderer.registerPlugin('batch', BatchRenderer);
|
||||||
|
Renderer.registerPlugin('tilingSprite', TilingSpriteRenderer);
|
||||||
|
|
||||||
|
Loader.registerPlugin(BitmapFontLoader);
|
||||||
|
Loader.registerPlugin(CompressedTextureLoader);
|
||||||
|
Loader.registerPlugin(DDSLoader);
|
||||||
|
Loader.registerPlugin(KTXLoader);
|
||||||
|
Loader.registerPlugin(SpritesheetLoader);
|
||||||
|
|
||||||
|
Application.registerPlugin(TickerPlugin);
|
||||||
|
Application.registerPlugin(AppLoaderPlugin);
|
@ -1,16 +1,17 @@
|
|||||||
|
import { SCALE_MODES } from '@pixi/constants';
|
||||||
|
import { AbstractRenderer, Renderer, RenderTexture, Resource, Texture } from '@pixi/core';
|
||||||
|
import { DisplayObject } from '@pixi/display';
|
||||||
import { Extract } from '@pixi/extract';
|
import { Extract } from '@pixi/extract';
|
||||||
import { AbstractRenderer, DisplayObject, Rectangle, Renderer, RenderTexture, Resource, SCALE_MODES, Texture } from 'pixi.js';
|
import { Rectangle } from '@pixi/math';
|
||||||
import { Nitro } from '../../nitro/Nitro';
|
import { Nitro } from '../../nitro/Nitro';
|
||||||
|
|
||||||
export class TextureUtils
|
export class TextureUtils
|
||||||
{
|
{
|
||||||
private static _renderer: Renderer = null;
|
|
||||||
|
|
||||||
public static generateTexture(displayObject: DisplayObject, region: Rectangle = null, scaleMode: number = SCALE_MODES.NEAREST, resolution: number = 1): RenderTexture
|
public static generateTexture(displayObject: DisplayObject, region: Rectangle = null, scaleMode: number = SCALE_MODES.NEAREST, resolution: number = 1): RenderTexture
|
||||||
{
|
{
|
||||||
if(!displayObject) return null;
|
if(!displayObject) return null;
|
||||||
|
|
||||||
return TextureUtils.getRenderer().generateTexture(displayObject, {
|
return this.getRenderer().generateTexture(displayObject, {
|
||||||
scaleMode,
|
scaleMode,
|
||||||
resolution,
|
resolution,
|
||||||
region
|
region
|
||||||
@ -28,38 +29,30 @@ export class TextureUtils
|
|||||||
{
|
{
|
||||||
if(!target) return null;
|
if(!target) return null;
|
||||||
|
|
||||||
const extract = (TextureUtils.getRenderer().plugins.extract as Extract);
|
return this.getExtractor().image(target);
|
||||||
|
|
||||||
return extract.image(target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static generateImageUrl(target: DisplayObject | RenderTexture): string
|
public static generateImageUrl(target: DisplayObject | RenderTexture): string
|
||||||
{
|
{
|
||||||
if(!target) return null;
|
if(!target) return null;
|
||||||
|
|
||||||
const extract = (TextureUtils.getRenderer().plugins.extract as Extract);
|
return this.getExtractor().base64(target);
|
||||||
|
|
||||||
return extract.base64(target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static generateCanvas(target: DisplayObject | RenderTexture): HTMLCanvasElement
|
public static generateCanvas(target: DisplayObject | RenderTexture): HTMLCanvasElement
|
||||||
{
|
{
|
||||||
if(!target) return null;
|
if(!target) return null;
|
||||||
|
|
||||||
const extract = (TextureUtils.getRenderer().plugins.extract as Extract);
|
return this.getExtractor().canvas(target);
|
||||||
|
|
||||||
return extract.canvas(target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getRenderer(): Renderer | AbstractRenderer
|
public static getRenderer(): Renderer | AbstractRenderer
|
||||||
{
|
{
|
||||||
if(!TextureUtils._renderer) return Nitro.instance.renderer;
|
return Nitro.instance.renderer;
|
||||||
|
|
||||||
return TextureUtils._renderer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static setRenderer(renderer: Renderer): void
|
public static getExtractor(): Extract
|
||||||
{
|
{
|
||||||
TextureUtils._renderer = renderer;
|
return (this.getRenderer().plugins.extract as Extract);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user