chore: bump pixi to v5

This commit is contained in:
cha0s 2019-10-27 13:34:44 -05:00
parent ee7608c211
commit 91c18df5e5
10 changed files with 51 additions and 56 deletions

21
TODO.md
View File

@ -16,7 +16,6 @@
- ✔ Entity packets - ✔ Entity packets
- ✔ Decouple input normalization from action registry - ✔ Decouple input normalization from action registry
- ✔ entityList.fromJSON() - ✔ entityList.fromJSON()
- ❌ Socket WebWorker can't connect in Firefox
- ✔ Don't run emitter destruction tickers on server - ✔ Don't run emitter destruction tickers on server
- ✔ Investigate unrolling equalsClose - ✔ Investigate unrolling equalsClose
- ✔ Bitshifts for on_positionChanged x/y boxing - ✔ Bitshifts for on_positionChanged x/y boxing
@ -24,19 +23,23 @@
- ✔ EE optimizations (lookupEmitListeners) - ✔ EE optimizations (lookupEmitListeners)
- ✔ Core.fastApply, search for /\(\.\.\./ - ✔ Core.fastApply, search for /\(\.\.\./
- ✔ Rename visibleBoundingBox(es)? to visibleAabb(s)? - ✔ Rename visibleBoundingBox(es)? to visibleAabb(s)?
- ❌ Property.fastAccess to skip getter, this.entity.currentAnimation
- ✔ Trait params fromJS is super slow - ✔ Trait params fromJS is super slow
- ✔ Entity::is is slow? - ✔ Entity::is is slow?
- Manual state sync - Manual state sync
- ✔ Synchronized provides packet updates - ✔ Synchronized provides packet updates
- ✔ Phase out EntityPacketSynchronizer - ✔ Phase out EntityPacketSynchronizer
- ❌ Implement ALL trait state update packets - ✔ Implement ALL trait state update packets
- ❌ Implement Entity remember packets
- ✔ Implement Entity remove packets - ✔ Implement Entity remove packets
- ✔ Save state/param extensions separately on create instead of only merging - ✔ Save state/param extensions separately on create instead of only merging
- ❌ Pointer events polyfill: https://github.com/jquery/PEP - ✔ Target trait updates beyond just visible; e.g. others don't need to know
- ❌ Target trait updates beyond just visible; e.g. others don't need to know
about inventory change about inventory change
- ❌ afterDestructionTickers shouldn't exist... destruction should be deferred - ✔ Remove position pack check from trait and add to Vector
- ❌ Remove position pack check from trait and add to Vector - ❌ PIXI particles
- ❌ Pointer events polyfill: https://github.com/jquery/PEP
- ❌ Fix physics drag during latency
- ❌ Socket WebWorker can't connect in Firefox
- ✔ PIXI update to v5
- ❌ chunked tile communication
- ❌ Property.fastAccess to skip getter, this.entity.currentAnimation
- ❌ zLib dictionary for packet compression - ❌ zLib dictionary for packet compression
- ❌ afterDestructionTickers shouldn't exist... destruction should be deferred

View File

@ -1,4 +1,4 @@
const PIXI = 'undefined' !== typeof window ? require('pixi.js') : undefined; import {RenderTexture} from '@pixi/core';
import {compose} from '@avocado/core'; import {compose} from '@avocado/core';
import {Vector} from '@avocado/math'; import {Vector} from '@avocado/math';
@ -15,7 +15,7 @@ export class Canvas extends decorate(class {}) {
constructor(size = [0, 0]) { constructor(size = [0, 0]) {
super(); super();
this.renderTexture = PIXI.RenderTexture.create(size[0], size[1]); this.renderTexture = RenderTexture.create(size[0], size[1]);
} }
destroy() { destroy() {

View File

@ -1,4 +1,6 @@
const PIXI = 'undefined' !== typeof window ? require('pixi.js') : undefined; import {Container as PIXIContainer} from '@pixi/display';
import {AdvancedBloomFilter} from '@pixi/filter-advanced-bloom';
import {ColorMatrixFilter} from '@pixi/filter-color-matrix';
import {Renderable} from './renderable'; import {Renderable} from './renderable';
@ -8,7 +10,7 @@ export class Container extends Renderable {
super(); super();
this._children = []; this._children = [];
this._childrenIndexes = new Map(); this._childrenIndexes = new Map();
this.container = PIXI ? new PIXI.Container() : undefined; this.container = new PIXIContainer();
} }
addChild(child) { addChild(child) {
@ -24,7 +26,7 @@ export class Container extends Renderable {
} }
desaturate() { desaturate() {
let filter = new PIXI.filters.ColorMatrixFilter(); let filter = new ColorMatrixFilter();
filter.desaturate(); filter.desaturate();
this.container.filters = [filter]; this.container.filters = [filter];
} }
@ -48,12 +50,12 @@ export class Container extends Renderable {
if ( if (
filters filters
&& filters.length > 0 && filters.length > 0
&& filters[0] instanceof PIXI.filters.ColorMatrixFilter && filters[0] instanceof ColorMatrixFilter
) { ) {
filter = filters[0]; filter = filters[0];
} }
else { else {
filter = new PIXI.filters.ColorMatrixFilter(); filter = new ColorMatrixFilter();
} }
const nightness = 0.1; const nightness = 0.1;
const double = nightness * 2; const double = nightness * 2;
@ -72,7 +74,7 @@ export class Container extends Renderable {
} }
paused(intensity = 1) { paused(intensity = 1) {
let filter = new PIXI.filters.ColorMatrixFilter(); let filter = new ColorMatrixFilter();
filter.sepia(); filter.sepia();
filter.brightness(1 - intensity, true); filter.brightness(1 - intensity, true);
this.container.filters = [filter]; this.container.filters = [filter];
@ -146,7 +148,7 @@ export class Container extends Renderable {
} }
sepia() { sepia() {
let filter = new PIXI.filters.ColorMatrixFilter(); let filter = new ColorMatrixFilter();
filter.sepia(); filter.sepia();
this.container.filters = [filter]; this.container.filters = [filter];
} }
@ -154,7 +156,6 @@ export class Container extends Renderable {
setFilter(filter) { setFilter(filter) {
switch (filter) { switch (filter) {
case 'bloom': case 'bloom':
const {AdvancedBloomFilter} = require('@pixi/filter-advanced-bloom');
this.container.filters = [new AdvancedBloomFilter({ this.container.filters = [new AdvancedBloomFilter({
threshold: 0.5, threshold: 0.5,
bloomScale: .8, bloomScale: .8,

View File

@ -1,4 +1,5 @@
const PIXI = 'undefined' !== typeof window ? require('pixi.js') : undefined; import {BaseTexture, Texture} from '@pixi/core';
import {SCALE_MODES} from '@pixi/constants';
import {Resource} from '@avocado/resource'; import {Resource} from '@avocado/resource';
@ -14,12 +15,12 @@ export class Image extends Resource {
} }
static fromHtmlCanvas(htmlCanvas) { static fromHtmlCanvas(htmlCanvas) {
const baseTexture = PIXI.BaseTexture.fromCanvas( const baseTexture = BaseTexture.from(
htmlCanvas, htmlCanvas,
PIXI.SCALE_MODES.NEAREST SCALE_MODES.NEAREST
); );
const image = new Image(); const image = new Image();
image.texture = new PIXI.Texture(baseTexture); image.texture = new Texture(baseTexture);
return image; return image;
} }
@ -27,7 +28,7 @@ export class Image extends Resource {
return this.loadBaseTexture(uri).then((baseTexture) => { return this.loadBaseTexture(uri).then((baseTexture) => {
const image = new Image(); const image = new Image();
image.uri = uri; image.uri = uri;
image.texture = new PIXI.Texture(baseTexture); image.texture = new Texture(baseTexture);
return image; return image;
}); });
} }
@ -40,7 +41,7 @@ export class Image extends Resource {
return Promise.resolve(this.baseTextureCache[uri]); return Promise.resolve(this.baseTextureCache[uri]);
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const baseTexture = PIXI.BaseTexture.fromImage(uri); const baseTexture = BaseTexture.from(uri);
baseTexture.once('error', () => { baseTexture.once('error', () => {
reject(new Error(`Couldn't load image "${uri}"`)); reject(new Error(`Couldn't load image "${uri}"`));
}); });
@ -69,7 +70,7 @@ export class Image extends Resource {
height: rectangle[3], height: rectangle[3],
}; };
const subimage = new Image(); const subimage = new Image();
subimage.texture = new PIXI.Texture(this.texture, frame); subimage.texture = new Texture(this.texture, frame);
return subimage; return subimage;
} }

View File

@ -1,4 +1,6 @@
const PIXI = 'undefined' !== typeof window ? require('pixi.js') : undefined; import {SCALE_MODES} from '@pixi/constants';
import {Renderer, BatchRenderer} from '@pixi/core';
import {settings} from '@pixi/settings';
export {Canvas} from './canvas'; export {Canvas} from './canvas';
export {Color} from './color'; export {Color} from './color';
@ -13,10 +15,6 @@ export {Stage} from './stage';
// Proton. // Proton.
export {Proton, TextNode, TextNodeRenderer} from './proton'; export {Proton, TextNode, TextNodeRenderer} from './proton';
// Pixelly! // Pixelly!
if (PIXI) { settings.SCALE_MODE = SCALE_MODES.NEAREST;
PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST // Lil pixi manegement.
// Kill PIXI's ticker. Renderer.registerPlugin('batch', BatchRenderer);
const ticker = PIXI.ticker.shared;
ticker.autoStart = false;
ticker.stop();
}

View File

@ -1,6 +1,6 @@
{ {
"name": "@avocado/graphics", "name": "@avocado/graphics",
"version": "1.0.6", "version": "1.0.8",
"main": "index.js", "main": "index.js",
"author": "cha0s", "author": "cha0s",
"license": "MIT", "license": "MIT",
@ -8,12 +8,12 @@
"@avocado/core": "1.x", "@avocado/core": "1.x",
"@avocado/math": "1.x", "@avocado/math": "1.x",
"@avocado/resource": "1.x", "@avocado/resource": "1.x",
"@pixi/filter-advanced-bloom": "2.7.0", "@pixi/filter-advanced-bloom": "3.0.3",
"debug": "3.1.0", "debug": "3.1.0",
"immutable": "4.0.0-rc.12", "immutable": "4.0.0-rc.12",
"pixi.js": "4.8.6", "pixi.js": "5.1.5",
"proton-js": "3.1.2",
"three": "0.103.0", "three": "0.103.0",
"three.proton.js": "0.1.5",
"web-animations-js": "2.3.1" "web-animations-js": "2.3.1"
} }
} }

View File

@ -1,4 +1,4 @@
const PIXI = 'undefined' !== typeof window ? require('pixi.js') : undefined; import {Graphics} from '@pixi/graphics';
import {Color} from './color'; import {Color} from './color';
import {Renderable} from './renderable'; import {Renderable} from './renderable';
@ -15,7 +15,7 @@ export class Primitives extends Renderable {
constructor() { constructor() {
super(); super();
this.primitives = new PIXI.Graphics(); this.primitives = new Graphics();
} }
clear() { clear() {

View File

@ -1,19 +1,12 @@
const PIXI = 'undefined' !== typeof window ? require('pixi.js') : undefined; import {Renderer as PIXIRenderer} from '@pixi/core';
export class Renderer { export class Renderer {
constructor(size = [0, 0], type = 'auto') { constructor(size = [0, 0], type = 'auto') {
switch (type) { this.renderer = new PIXIRenderer(size[0], size[1]);
case 'auto': // Need to set size explicitly since v5.
this.renderer = PIXI.autoDetectRenderer(size[0], size[1]); this.renderer.view.width = size[0];
break; this.renderer.view.height = size[1];
case 'canvas':
this.renderer = new PIXI.CanvasRenderer(size[0], size[1]);
break;
case 'webgl':
this.renderer = new PIXI.WebGLRenderer(size[0], size[1]);
break;
}
} }
destroy() { destroy() {

View File

@ -1,4 +1,4 @@
const PIXI = 'undefined' !== typeof window ? require('pixi.js') : undefined; import {Sprite as PIXISprite} from '@pixi/sprite';
import {Renderable} from './renderable'; import {Renderable} from './renderable';
@ -7,7 +7,7 @@ export class Sprite extends Renderable {
constructor(image) { constructor(image) {
super(); super();
this._image = image; this._image = image;
this.sprite = new PIXI.Sprite(image.texture); this.sprite = new PIXISprite(image.texture);
this.anchor = [0.5, 0.5]; this.anchor = [0.5, 0.5];
} }
@ -26,6 +26,7 @@ export class Sprite extends Renderable {
width: rectangle[2], width: rectangle[2],
height: rectangle[3], height: rectangle[3],
}; };
this._image.texture.updateUvs();
} }
} }

View File

@ -1,5 +1,3 @@
const PIXI = 'undefined' !== typeof window ? require('pixi.js') : undefined;
import * as THREE from 'three'; import * as THREE from 'three';
import {compose, Property} from '@avocado/core'; import {compose, Property} from '@avocado/core';