🆙 Fix firework memory leak and update pixi.js

This commit is contained in:
duckietm 2024-09-13 08:04:35 +02:00
parent 1e4f45a107
commit 14bf0fdcbd
23 changed files with 417 additions and 1469 deletions

View File

@ -30,21 +30,21 @@
"dependencies": {
"howler": "^2.2.4",
"pako": "^2.1.0",
"pixi-filters": "^6.0.4",
"pixi.js": "^8.1.6",
"pixi-filters": "^6.0.5",
"pixi.js": "^8.4.0",
"clientjs": "^0.2.1"
},
"devDependencies": {
"@eslint/js": "^9.5.0",
"@eslint/js": "^9.8.0",
"@rollup/plugin-typescript": "^11.1.6",
"@types/eslint__js": "^8.42.3",
"@types/howler": "^2.2.11",
"@types/node": "^20.14.4",
"@types/node": "^20.14.12",
"@types/pako": "^2.0.3",
"eslint": "^9.5.0",
"tslib": "^2.3.1",
"typescript": "~5.4.2",
"typescript-eslint": "^7.13.1",
"vite": "^5.1.3"
"eslint": "^9.8.0",
"tslib": "^2.6.3",
"typescript": "~5.5.4",
"typescript-eslint": "^7.17.0",
"vite": "^5.4.0"
}
}

View File

@ -12,9 +12,9 @@
},
"main": "./index",
"dependencies": {
"pixi.js": "^8.1.6"
"pixi.js": "^8.2.5"
},
"devDependencies": {
"typescript": "~5.4.2"
"typescript": "~5.5.4"
}
}

View File

@ -23,6 +23,7 @@ export class RoomObjectVariable
public static FURNITURE_PURCHASER_NAME: string = 'furniture_purchaser_name';
public static FURNITURE_PURCHASER_FIGURE: string = 'furniture_purchaser_figure';
public static STD: string = 'std';
public static SWIM: string = 'swm';
public static FIGURE_SIGN: string = 'figure_sign';
public static FIGURE_FLAT_CONTROL: string = 'figure_flat_control';
public static FIGURE_IS_TYPING: string = 'figure_is_typing';

View File

@ -14,10 +14,10 @@
"dependencies": {
"@nitrots/api": "1.0.0",
"@nitrots/utils": "1.0.0",
"pixi.js": "^8.1.6",
"pixi.js": "^8.2.5",
"@pixi/gif": "^3.0.0"
},
"devDependencies": {
"typescript": "~5.4.2"
"typescript": "~5.5.4"
}
}

View File

@ -15,6 +15,6 @@
"@nitrots/utils": "1.0.0"
},
"devDependencies": {
"typescript": "~5.4.2"
"typescript": "~5.5.4"
}
}

View File

@ -822,6 +822,224 @@ export const HabboAvatarAnimations = {
}
]
}
},
{
'id': 'Swim',
'parts': [
{
'setType': 'bds',
'frames': [
{
'number': 0,
'assetPartDefinition': 'swm'
},
{
'number': 1,
'assetPartDefinition': 'swm'
},
{
'number': 2,
'assetPartDefinition': 'swm'
},
{
'number': 3,
'assetPartDefinition': 'swm'
}
]
},
{
'setType': 'ss',
'frames': [
{
'number': 0,
'assetPartDefinition': 'swm'
},
{
'number': 1,
'assetPartDefinition': 'swm'
},
{
'number': 2,
'assetPartDefinition': 'swm'
},
{
'number': 3,
'assetPartDefinition': 'swm'
}
]
},
{
'setType': 'lhs',
'frames': [
{
'number': 0,
'assetPartDefinition': 'swm'
},
{
'number': 1,
'assetPartDefinition': 'swm'
},
{
'number': 2,
'assetPartDefinition': 'swm'
},
{
'number': 3,
'assetPartDefinition': 'swm'
}
]
},
{
'setType': 'rhs',
'frames': [
{
'number': 0,
'assetPartDefinition': 'swm'
},
{
'number': 1,
'assetPartDefinition': 'swm'
},
{
'number': 2,
'assetPartDefinition': 'swm'
},
{
'number': 3,
'assetPartDefinition': 'swm'
}
]
},
]
},
{
'id': 'Float',
'parts': [
{
'setType': 'bds',
'frames': [
{
'number': 3,
'assetPartDefinition': 'sws'
},
{
'number': 3,
'assetPartDefinition': 'sws'
},
{
'number': 2,
'assetPartDefinition': 'sws'
},
{
'number': 1,
'assetPartDefinition': 'sws'
},
{
'number': 0,
'assetPartDefinition': 'sws'
}
]
},
{
'setType': 'ss',
'frames': [
{
'number': 0,
'assetPartDefinition': 'sws'
}
]
},
{
'setType': 'lhs',
'frames': [
{
'number': 0,
'assetPartDefinition': 'sws'
},
{
'number': 0,
'assetPartDefinition': 'sws'
},
{
'number': 1,
'assetPartDefinition': 'sws'
},
{
'number': 1,
'assetPartDefinition': 'sws'
},
{
'number': 2,
'assetPartDefinition': 'sws'
},
{
'number': 3,
'assetPartDefinition': 'sws'
},
{
'number': 3,
'assetPartDefinition': 'sws'
},
{
'number': 2,
'assetPartDefinition': 'sws'
},
{
'number': 1,
'assetPartDefinition': 'sws'
},
{
'number': 1,
'assetPartDefinition': 'sws'
}
]
},
{
'setType': 'rhs',
'frames': [
{
'number': 0,
'assetPartDefinition': 'sws'
},
{
'number': 0,
'assetPartDefinition': 'sws'
},
{
'number': 1,
'assetPartDefinition': 'sws'
},
{
'number': 1,
'assetPartDefinition': 'sws'
},
{
'number': 2,
'assetPartDefinition': 'sws'
},
{
'number': 3,
'assetPartDefinition': 'sws'
},
{
'number': 3,
'assetPartDefinition': 'sws'
},
{
'number': 2,
'assetPartDefinition': 'sws'
},
{
'number': 1,
'assetPartDefinition': 'sws'
},
{
'number': 1,
'assetPartDefinition': 'sws'
}
]
},
]
},
]
};

View File

@ -75,8 +75,8 @@ export const HabboAvatarGeometry = {
'id': 'swim',
'width': 64,
'height': 70,
'dx': 25,
'dy': 10
'dx': 0,
'dy': 0
}
]
}
@ -1715,6 +1715,46 @@ export const HabboAvatarGeometry = {
}
]
},
{
'id': 'leftarm',
'x': -1,
'y': 0,
'z': 0.0,
'radius': 0.6,
'items': [
{
'id': 'lhs',
'x': 0,
'y': 0,
'z': 0,
'radius': 0.01,
'nx': 0,
'ny': 0,
'nz': -1,
'double': false
}
]
},
{
'id': 'rightarm',
'x': 1,
'y': 0,
'z': 0.0,
'radius': 0.6,
'items': [
{
'id': 'rhs',
'x': 0,
'y': 0,
'z': 0,
'radius': 0.01,
'nx': 0,
'ny': 0,
'nz': -1,
'double': false
}
]
},
{
'id': 'head',
'x': 0,

View File

@ -412,6 +412,72 @@ export const HabboAvatarPartSets = {
'setType': 'ri'
}
]
},
{
'id': 'swim',
'activeParts': [
{
'setType': 'bds'
},
{
'setType': 'ss'
},
{
'setType': 'lhs'
},
{
'setType': 'rhs'
}
]
},
{
'id': 'snowwarrun',
'activeParts': [
{
'setType': 'ch'
}
]
},
{
'id': 'snowwarpick',
'activeParts': [
{
'setType': 'ch'
},
{
'setType': 'hd'
}
]
},
{
'id': 'snowwardiefront',
'activeParts': [
{
'setType': 'ch'
},
{
'setType': 'hd'
}
]
},
{
'id': 'snowwardieback',
'activeParts': [
{
'setType': 'ch'
},
{
'setType': 'hd'
}
]
},
{
'id': 'snowwarthrow',
'activeParts': [
{
'setType': 'ch'
}
]
}
]
}

View File

@ -14,9 +14,9 @@
"@nitrots/configuration": "1.0.0",
"@nitrots/events": "1.0.0",
"@nitrots/utils": "1.0.0",
"pixi.js": "^8.1.6"
"pixi.js": "^8.2.5"
},
"devDependencies": {
"typescript": "~5.4.2"
"typescript": "~5.5.4"
}
}

View File

@ -14,6 +14,6 @@
"@nitrots/utils": "1.0.0"
},
"devDependencies": {
"typescript": "~5.4.2"
"typescript": "~5.5.4"
}
}

View File

@ -103,10 +103,10 @@ export class RoomUnitStatusParser implements IMessageParser
break;
}
}
}
statusActions.push(new RoomUnitStatusAction(parts[0], parts[1]));
}
}
this._statuses.push(new RoomUnitStatusMessage(unitId, x, y, z, height, headDirection, direction, targetX, targetY, targetZ, didMove, canStandUp, statusActions));
}

View File

@ -13,6 +13,6 @@
"@nitrots/utils": "1.0.0"
},
"devDependencies": {
"typescript": "~5.4.2"
"typescript": "~5.5.4"
}
}

View File

@ -13,6 +13,6 @@
"@nitrots/utils": "1.0.0"
},
"devDependencies": {
"typescript": "~5.4.2"
"typescript": "~5.5.4"
}
}

View File

@ -13,9 +13,9 @@
"@nitrots/communication": "1.0.0",
"@nitrots/configuration": "1.0.0",
"@nitrots/events": "1.0.0",
"pixi.js": "^8.1.6"
"pixi.js": "^8.2.5"
},
"devDependencies": {
"typescript": "~5.4.2"
"typescript": "~5.5.4"
}
}

View File

@ -16,9 +16,9 @@
"@nitrots/configuration": "1.0.0",
"@nitrots/events": "1.0.0",
"@nitrots/session": "1.0.0",
"pixi.js": "^8.1.6"
"pixi.js": "^8.2.5"
},
"devDependencies": {
"typescript": "~5.4.2"
"typescript": "~5.5.4"
}
}

View File

@ -712,6 +712,8 @@ export class RoomMessageHandler
let postureUpdate = false;
let postureType = RoomObjectVariable.STD;
let parameter = '';
let moveUpdate = false;
let swimUpdate = false;
if(status.actions && status.actions.length)
{
@ -736,6 +738,13 @@ export class RoomMessageHandler
break;
case 'wav':
case 'mv':
moveUpdate = true;
postureUpdate = true;
postureType = action.action;
parameter = action.value;
break;
case 'swim':
swimUpdate = true;
postureUpdate = true;
postureType = action.action;
parameter = action.value;
@ -750,6 +759,12 @@ export class RoomMessageHandler
}
}
if(!moveUpdate && swimUpdate)
{
postureUpdate = true;
postureType = 'float';
}
if(postureUpdate) this._roomEngine.updateRoomObjectUserPosture(this._currentRoomId, status.id, postureType, parameter);
else if(isPosture) this._roomEngine.updateRoomObjectUserPosture(this._currentRoomId, status.id, RoomObjectVariable.STD, '');
}

View File

@ -26,6 +26,7 @@ export class FurnitureParticleSystem
private _blend: number = 1;
private _bgColor: number = 0xFF000000;
private _emptySprite: Sprite;
private _particleSprite: Sprite;
private _isDone: boolean = false;
constructor(visualization: FurnitureAnimatedVisualization)
@ -37,6 +38,7 @@ export class FurnitureParticleSystem
this._particleColorTransform = new AlphaFilter();
this._identityMatrix = new Matrix();
this._translationMatrix = new Matrix();
this._particleSprite = new Sprite();
}
public dispose(): void
@ -63,6 +65,12 @@ export class FurnitureParticleSystem
this._emptySprite = null;
}
if (this._particleSprite)
{
this._particleSprite.destroy();
this._particleSprite = null;
}
this._blackOverlayAlphaTransform = null;
this._particleColorTransform = null;
this._identityMatrix = null;
@ -101,7 +109,11 @@ export class FurnitureParticleSystem
{
if((this._roomSprite.width <= 1) || (this._roomSprite.height <= 1)) return;
if(this._canvasTexture && ((this._canvasTexture.width !== this._roomSprite.width) || (this._canvasTexture.height !== this._roomSprite.height))) this._canvasTexture = null;
if(this._canvasTexture && ((this._canvasTexture.width !== this._roomSprite.width) || (this._canvasTexture.height !== this._roomSprite.height)))
{
this._canvasTexture.destroy();
this._canvasTexture = null;
}
this.clearCanvas();
@ -172,43 +184,50 @@ export class FurnitureParticleSystem
const ty = ((this._centerY - offsetY) + ((((particle.y + ((particle.x + particle.z) / 2)) * k) / 10) * this._scaleMultiplier));
const asset = particle.getAsset();
this._particleSprite.texture = null;
this._particleSprite.tint = 0xFFFFFF;
this._particleSprite.width = 1;
this._particleSprite.height = 1;
this._particleSprite.x = 0;
this._particleSprite.y = 0;
this._particleSprite.filters = [];
if(asset && asset.texture)
{
this._particleSprite.texture = asset.texture;
this._particleSprite.width = asset.texture.width;
this._particleSprite.height = asset.texture.height;
if(particle.fade && (particle.alphaMultiplier < 1))
{
this._translationMatrix.identity();
this._translationMatrix.translate((tx + asset.offsetX), (ty + asset.offsetY));
const sprite = new Sprite(asset.texture);
this._particleColorTransform.alpha = particle.alphaMultiplier;
sprite.filters = [this._particleColorTransform];
this._particleSprite.filters = [this._particleColorTransform];
TextureUtils.writeToTexture(sprite, this._canvasTexture, false, this._translationMatrix);
TextureUtils.writeToTexture(this._particleSprite, this._canvasTexture, false, this._translationMatrix);
}
else
{
const point = new Point((tx + asset.offsetX), (ty + asset.offsetY));
const sprite = new Sprite(asset.texture);
sprite.x = point.x;
sprite.y = point.y;
this._particleSprite.x = point.x;
this._particleSprite.y = point.y;
TextureUtils.writeToTexture(sprite, this._canvasTexture, false);
TextureUtils.writeToTexture(this._particleSprite, this._canvasTexture, false);
}
}
else
{
const sprite = new Sprite(Texture.WHITE);
this._particleSprite.tint = 0xFFFFFF;
this._particleSprite.x = (tx - 1);
this._particleSprite.y = (ty - 1);
this._particleSprite.width = 2;
this._particleSprite.height = 2;
sprite.tint = 0xFFFFFF;
sprite.x = (tx - 1);
sprite.y = (ty - 1);
sprite.width = 2;
sprite.height = 2;
TextureUtils.writeToTexture(sprite, this._canvasTexture, false);
TextureUtils.writeToTexture(this._particleSprite, this._canvasTexture, false);
}
}
@ -289,15 +308,17 @@ export class FurnitureParticleSystem
if(this._currentEmitter) this._currentEmitter.copyStateFrom(particleSystem._currentEmitter, (particleSystem._size / this._size));
if (this._canvasTexture) {
this._canvasTexture.destroy();
this._canvasTexture = null;
}
}
private clearCanvas(): void
{
if(!this._emptySprite)
{
this._emptySprite = new Sprite(Texture.EMPTY);
this._emptySprite.alpha = 0;
}

View File

@ -15,9 +15,9 @@
"@nitrots/configuration": "1.0.0",
"@nitrots/events": "1.0.0",
"@nitrots/localization": "1.0.0",
"pixi.js": "^8.1.6"
"pixi.js": "^8.2.5"
},
"devDependencies": {
"typescript": "~5.4.2"
"typescript": "~5.5.4"
}
}

View File

@ -11,9 +11,9 @@
"dependencies": {
"@nitrots/api": "1.0.0",
"@nitrots/communication": "1.0.0",
"pixi.js": "^8.1.6"
"pixi.js": "^8.2.5"
},
"devDependencies": {
"typescript": "~5.4.2"
"typescript": "~5.5.4"
}
}

View File

@ -11,10 +11,10 @@
"dependencies": {
"@nitrots/api": "1.0.0",
"pako": "^2.1.0",
"pixi.js": "^8.1.6"
"pixi.js": "^8.2.5"
},
"devDependencies": {
"@types/pako": "^2.0.3",
"typescript": "~5.4.2"
"typescript": "~5.5.4"
}
}

View File

@ -1,5 +1,4 @@
import { BufferImageSource, Filter, FilterSystem, GlProgram, RenderSurface, Texture } from 'pixi.js';
import { TextureUtils } from '../TextureUtils';
export interface PaletteMapFilterOptions
{
@ -98,11 +97,6 @@ export class PaletteMapFilter extends Filter
})
});
(async () =>
{
console.log(await TextureUtils.generateImageUrl(lutTexture));
})();
super({
gpuProgram: null,
glProgram,

View File

@ -1,6 +1,4 @@
import { GetRoomEngine, RoomEngine } from '@nitrots/room';
import { GetRenderer, GetTexturePool } from '@nitrots/utils';
import { Texture, TextureGCSystem, TextureSource } from 'pixi.js';
export { };
declare global
@ -9,17 +7,11 @@ declare global
{
NitroDevTools?:
{
roomEngine(): RoomEngine;
textureCache(): TextureSource<any>[];
texturePool(): { [index: string]: { [index: string]: Texture[] } };
textureGC(): TextureGCSystem;
roomEngine: RoomEngine;
};
}
}
window.NitroDevTools = {
roomEngine: () => GetRoomEngine(),
textureCache: () => GetRenderer().texture.managedTextures,
texturePool: () => GetTexturePool().textures,
textureGC: () => GetRenderer().textureGC
roomEngine: GetRoomEngine()
};

1399
yarn.lock

File diff suppressed because it is too large Load Diff