Updated the renderer V2

This commit is contained in:
duckietm 2024-04-25 11:35:50 +02:00
parent 95bc0045ec
commit d5a3a05c40
20 changed files with 166 additions and 250 deletions

View File

@ -14,7 +14,7 @@
}, },
"main": "./index", "main": "./index",
"dependencies": { "dependencies": {
"pixi.js": "^8.0.4" "pixi.js": "^8.1.0"
}, },
"devDependencies": { "devDependencies": {
"typescript": "~5.4.2" "typescript": "~5.4.2"

View File

@ -16,7 +16,7 @@
"@nitrots/api": "1.0.0", "@nitrots/api": "1.0.0",
"@nitrots/eslint-config": "1.0.0", "@nitrots/eslint-config": "1.0.0",
"@nitrots/utils": "1.0.0", "@nitrots/utils": "1.0.0",
"pixi.js": "^8.0.4", "pixi.js": "^8.1.0",
"@pixi/gif": "^3.0.0" "@pixi/gif": "^3.0.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -117,9 +117,9 @@ export class AvatarStructure
this._animationManager.registerAnimation(this, data); this._animationManager.registerAnimation(this, data);
} }
public getPartColor(k: IAvatarFigureContainer, _arg_2: string, _arg_3: number = 0): IPartColor public getPartColor(container: IAvatarFigureContainer, _arg_2: string, _arg_3: number = 0): IPartColor
{ {
const _local_4 = k.getPartColorIds(_arg_2); const _local_4 = container.getPartColorIds(_arg_2);
if((!(_local_4)) || (_local_4.length < _arg_3)) return null; if((!(_local_4)) || (_local_4.length < _arg_3)) return null;

View File

@ -88,49 +88,54 @@ export class AvatarDataContainer implements IAvatarDataContainer
private generatePaletteMapForGrayscale(background: number, foreground: number): Map<string, number[]> private generatePaletteMapForGrayscale(background: number, foreground: number): Map<string, number[]>
{ {
const alphaBackground = ((background >> 24) & 0xFF); const alphaBackground = (background >> 24) & 0xFF;
const redBackground = ((background >> 16) & 0xFF); const redBackground = (background >> 16) & 0xFF;
const greenBackground = ((background >> 8) & 0xFF); const greenBackground = (background >> 8) & 0xFF;
const blueBackground = ((background >> 0) & 0xFF); const blueBackground = background & 0xFF;
const alphaForeground = ((foreground >> 24) & 0xFF);
const redForeground = ((foreground >> 16) & 0xFF); const alphaForeground = (foreground >> 24) & 0xFF;
const greenForeground = ((foreground >> 8) & 0xFF); const redForeground = (foreground >> 16) & 0xFF;
const blueForeground = ((foreground >> 0) & 0xFF); const greenForeground = (foreground >> 8) & 0xFF;
const alphaDifference = ((alphaForeground - alphaBackground) / 0xFF); const blueForeground = foreground & 0xFF;
const redDifference = ((redForeground - redBackground) / 0xFF);
const greenDifference = ((greenForeground - greenBackground) / 0xFF); const alphaStep = (alphaForeground - alphaBackground) / 255;
const blueDifference = ((blueForeground - blueBackground) / 0xFF); const redStep = (redForeground - redBackground) / 255;
const _local_15: Map<string, number[]> = new Map(); const greenStep = (greenForeground - greenBackground) / 255;
const _local_16: number[] = []; const blueStep = (blueForeground - blueBackground) / 255;
const _local_17: number[] = [];
const _local_18: number[] = []; const paletteMap: Map<string, number[]> = new Map();
const _local_19: number[] = []; const gradientColors: number[] = [];
let _local_20 = alphaBackground;
let _local_21 = redBackground; let currentAlpha = alphaBackground;
let _local_22 = greenBackground; let currentRed = redBackground;
let _local_23 = blueBackground; let currentGreen = greenBackground;
let currentBlue = blueBackground;
for(let i = 0; i < 256; i++) for(let i = 0; i < 256; i++)
{ {
if((((_local_21 == redBackground) && (_local_22 == greenBackground)) && (_local_23 == blueBackground))) // Update the current colors by their respective steps
{ currentAlpha += alphaStep;
_local_20 = 0; currentRed += redStep;
} currentGreen += greenStep;
_local_20 = (_local_20 + alphaDifference); currentBlue += blueStep;
_local_21 = (_local_21 + redDifference);
_local_22 = (_local_22 + greenDifference); // Clamp the color values between 0 and 255 to ensure valid color values
_local_23 = (_local_23 + blueDifference); const clampedAlpha = Math.max(0, Math.min(255, Math.round(currentAlpha)));
_local_19.push((_local_20 << 24)); const clampedRed = Math.max(0, Math.min(255, Math.round(currentRed)));
_local_16.push(((((_local_20 << 24) | (_local_21 << 16)) | (_local_22 << 8)) | _local_23)); const clampedGreen = Math.max(0, Math.min(255, Math.round(currentGreen)));
_local_17.push(((((_local_20 << 24) | (_local_21 << 16)) | (_local_22 << 8)) | _local_23)); const clampedBlue = Math.max(0, Math.min(255, Math.round(currentBlue)));
_local_18.push(((((_local_20 << 24) | (_local_21 << 16)) | (_local_22 << 8)) | _local_23));
// Combine the color components back into a single integer
const color = (clampedAlpha << 24) | (clampedRed << 16) | (clampedGreen << 8) | clampedBlue;
gradientColors.push(color);
} }
_local_15.set('alphas', _local_16); // Since the gradients for all color channels are the same, we use the same array
_local_15.set('reds', _local_16); paletteMap.set('alphas', gradientColors);
_local_15.set('greens', _local_17); paletteMap.set('reds', gradientColors);
_local_15.set('blues', _local_18); paletteMap.set('greens', gradientColors);
paletteMap.set('blues', gradientColors);
return _local_15; return paletteMap;
} }
} }

View File

@ -16,7 +16,7 @@
"@nitrots/eslint-config": "1.0.0", "@nitrots/eslint-config": "1.0.0",
"@nitrots/events": "1.0.0", "@nitrots/events": "1.0.0",
"@nitrots/utils": "1.0.0", "@nitrots/utils": "1.0.0",
"pixi.js": "^8.0.4" "pixi.js": "^8.1.0"
}, },
"devDependencies": { "devDependencies": {
"typescript": "~5.4.2" "typescript": "~5.4.2"

View File

@ -39,7 +39,7 @@ export class CommunicationManager implements ICommunicationManager
} }
private getCanvas(): any { private getCanvas(): any {
const e = document.createElement('canvas'), t = e.getContext('2d'), userAgent = navigator.userAgent, screenInfo = '${window.screen.width}x${window.screen.height}', currentDate = new Date().toString(), s = 'ThiosIsVerrySeCuRe02938883721##@@@_moreStuff! | ${userAgent} | ${screenInfo} | ${currentDate}'; const e = document.createElement('canvas'), t = e.getContext('2d'), userAgent = navigator.userAgent, screenInfo = '${window.screen.width}x${window.screen.height}', currentDate = new Date().toString(), s = 'ThiosIsVerrySeCuRe02938883721moreStuff! | ${userAgent} | ${screenInfo} | ${currentDate}';
t.textBaseline = 'top'; t.textBaseline = 'top';
t.font = "16px 'Arial'"; t.font = "16px 'Arial'";
t.textBaseline = 'alphabetic'; t.textBaseline = 'alphabetic';

File diff suppressed because one or more lines are too long

View File

@ -468,4 +468,8 @@ export class OutgoingHeader
public static RENTABLE_EXTEND_RENT_OR_BUYOUT_STRIP_ITEM = 2115; public static RENTABLE_EXTEND_RENT_OR_BUYOUT_STRIP_ITEM = 2115;
public static RENTABLE_EXTEND_RENT_OR_BUYOUT_FURNI = 1071; public static RENTABLE_EXTEND_RENT_OR_BUYOUT_FURNI = 1071;
public static RENTABLE_GET_RENT_OR_BUYOUT_OFFER = 2518; public static RENTABLE_GET_RENT_OR_BUYOUT_OFFER = 2518;
// CUSTOM HEADERS
public static DELETE_ITEM = 10018;
} }

View File

@ -0,0 +1,21 @@
import { IMessageComposer } from '../../../../../../api';
export class DeleteItemMessageComposer implements IMessageComposer<ConstructorParameters<typeof DeleteItemMessageComposer>>
{
private _data: ConstructorParameters<typeof DeleteItemMessageComposer>;
constructor(itemId: number, amount: number)
{
this._data = [itemId, amount];
}
public getMessageArray()
{
return this._data;
}
public dispose(): void
{
return;
}
}

View File

@ -1,2 +1,3 @@
export * from './DeleteItemMessageComposer';
export * from './FurnitureListComposer'; export * from './FurnitureListComposer';
export * from './RequestFurniInventoryWhenNotInRoomComposer'; export * from './RequestFurniInventoryWhenNotInRoomComposer';

View File

@ -15,7 +15,7 @@
"@nitrots/configuration": "1.0.0", "@nitrots/configuration": "1.0.0",
"@nitrots/eslint-config": "1.0.0", "@nitrots/eslint-config": "1.0.0",
"@nitrots/events": "1.0.0", "@nitrots/events": "1.0.0",
"pixi.js": "^8.0.4" "pixi.js": "^8.1.0"
}, },
"devDependencies": { "devDependencies": {
"typescript": "~5.4.2" "typescript": "~5.4.2"

View File

@ -18,7 +18,7 @@
"@nitrots/eslint-config": "1.0.0", "@nitrots/eslint-config": "1.0.0",
"@nitrots/events": "1.0.0", "@nitrots/events": "1.0.0",
"@nitrots/session": "1.0.0", "@nitrots/session": "1.0.0",
"pixi.js": "^8.0.4" "pixi.js": "^8.1.0"
}, },
"devDependencies": { "devDependencies": {
"typescript": "~5.4.2" "typescript": "~5.4.2"

View File

@ -85,12 +85,8 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
const display = new Container(); const display = new Container();
display.isRenderGroup = true; display.isRenderGroup = true;
display.cullableChildren = false; display.cullableChildren = false;
display.interactive = false;
display.interactiveChildren = false;
this._master.addChild(display); this._master.addChild(display);
this._display = display; this._display = display;
@ -584,7 +580,16 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
if(this._spritePool.length > 0) extendedSprite = this._spritePool.pop(); if(this._spritePool.length > 0) extendedSprite = this._spritePool.pop();
if(!extendedSprite) extendedSprite = new ExtendedSprite({}); let textureSet = false;
if(!extendedSprite)
{
extendedSprite = new ExtendedSprite({
texture: sprite.texture
});
textureSet = true;
}
if(extendedSprite.children.length) extendedSprite.removeChildren(); if(extendedSprite.children.length) extendedSprite.removeChildren();
@ -602,7 +607,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
extendedSprite.blendMode = sprite.blendMode; extendedSprite.blendMode = sprite.blendMode;
extendedSprite.filters = sprite.filters; extendedSprite.filters = sprite.filters;
extendedSprite.setTexture(sprite.texture); if(!textureSet) extendedSprite.setTexture(sprite.texture);
if(sprite.flipH) extendedSprite.scale.x = -1; if(sprite.flipH) extendedSprite.scale.x = -1;

View File

@ -10,5 +10,4 @@ export * from './RoomObjectBadgeImageAssetListener';
export * from './RoomRotatingEffect'; export * from './RoomRotatingEffect';
export * from './RoomShakingEffect'; export * from './RoomShakingEffect';
export * from './SelectedRoomObjectData'; export * from './SelectedRoomObjectData';
export * from './SpriteDataCollector';
export * from './TileObjectMap'; export * from './TileObjectMap';

View File

@ -17,7 +17,7 @@
"@nitrots/eslint-config": "1.0.0", "@nitrots/eslint-config": "1.0.0",
"@nitrots/events": "1.0.0", "@nitrots/events": "1.0.0",
"@nitrots/localization": "1.0.0", "@nitrots/localization": "1.0.0",
"pixi.js": "^8.0.4" "pixi.js": "^8.1.0"
}, },
"devDependencies": { "devDependencies": {
"typescript": "~5.4.2" "typescript": "~5.4.2"

View File

@ -13,7 +13,7 @@
"@nitrots/api": "1.0.0", "@nitrots/api": "1.0.0",
"@nitrots/communication": "1.0.0", "@nitrots/communication": "1.0.0",
"@nitrots/eslint-config": "1.0.0", "@nitrots/eslint-config": "1.0.0",
"pixi.js": "^8.0.4" "pixi.js": "^8.1.0"
}, },
"devDependencies": { "devDependencies": {
"typescript": "~5.4.2" "typescript": "~5.4.2"

View File

@ -13,7 +13,7 @@
"@nitrots/api": "1.0.0", "@nitrots/api": "1.0.0",
"@nitrots/eslint-config": "1.0.0", "@nitrots/eslint-config": "1.0.0",
"pako": "^2.1.0", "pako": "^2.1.0",
"pixi.js": "^8.0.4" "pixi.js": "^8.1.0"
}, },
"devDependencies": { "devDependencies": {
"@types/pako": "^2.0.3", "@types/pako": "^2.0.3",

View File

@ -57,212 +57,84 @@ export class ColorConverter
return 'rgba(' + [r, g, b, 1].join(',') + ')'; return 'rgba(' + [r, g, b, 1].join(',') + ')';
} }
public static rgbToHSL(k: number): number public static rgbToHSL(rgbValue: number): number
{ {
const _local_2: number = (((k >> 16) & 0xFF) / 0xFF); const red = ((rgbValue >> 16) & 0xFF) / 0xFF;
const _local_3: number = (((k >> 8) & 0xFF) / 0xFF); const green = ((rgbValue >> 8) & 0xFF) / 0xFF;
const _local_4: number = ((k & 0xFF) / 0xFF); const blue = (rgbValue & 0xFF) / 0xFF;
const _local_5: number = Math.max(_local_2, _local_3, _local_4);
const _local_6: number = Math.min(_local_2, _local_3, _local_4); const max = Math.max(red, green, blue);
const _local_7: number = (_local_5 - _local_6); const min = Math.min(red, green, blue);
let _local_8 = 0; const delta = max - min;
let _local_9 = 0;
let _local_10 = 0; let hue = 0;
if(_local_7 == 0) let saturation = 0;
const lightness = (max + min) / 2;
if(delta !== 0)
{ {
_local_8 = 0; saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
}
else switch(max)
{ {
if(_local_5 == _local_2) case red:
{ hue = (green - blue) / delta + (green < blue ? 6 : 0);
if(_local_3 > _local_4) break;
{ case green:
_local_8 = ((60 * (_local_3 - _local_4)) / _local_7); hue = (blue - red) / delta + 2;
} break;
else case blue:
{ hue = (red - green) / delta + 4;
_local_8 = (((60 * (_local_3 - _local_4)) / _local_7) + 360); break;
}
}
else
{
if(_local_5 == _local_3)
{
_local_8 = (((60 * (_local_4 - _local_2)) / _local_7) + 120);
}
else
{
if(_local_5 == _local_4)
{
_local_8 = (((60 * (_local_2 - _local_3)) / _local_7) + 240);
}
}
}
}
_local_9 = (0.5 * (_local_5 + _local_6));
if(_local_7 == 0)
{
_local_10 = 0;
}
else
{
if(_local_9 <= 0.5)
{
_local_10 = ((_local_7 / _local_9) * 0.5);
}
else
{
_local_10 = ((_local_7 / (1 - _local_9)) * 0.5);
}
}
const _local_11: number = Math.round(((_local_8 / 360) * 0xFF));
const _local_12: number = Math.round((_local_10 * 0xFF));
const _local_13: number = Math.round((_local_9 * 0xFF));
const _local_14: number = (((_local_11 << 16) + (_local_12 << 8)) + _local_13);
return _local_14;
} }
public static hslToRGB(k: number): number hue *= 60;
}
const h = Math.round((hue / 360) * 0xFF);
const s = Math.round(saturation * 0xFF);
const l = Math.round(lightness * 0xFF);
return (h << 16) + (s << 8) + l;
}
public static hslToRGB(hslValue: number): number
{ {
let _local_12: number; const hue = ((hslValue >> 16) & 0xFF) / 0xFF;
let _local_13: number; const saturation = ((hslValue >> 8) & 0xFF) / 0xFF;
let _local_14: number; const lightness = (hslValue & 0xFF) / 0xFF;
let _local_15: number;
let _local_16: number; let red = 0;
const _local_2: number = (((k >> 16) & 0xFF) / 0xFF); let green = 0;
const _local_3: number = (((k >> 8) & 0xFF) / 0xFF); let blue = 0;
const _local_4: number = ((k & 0xFF) / 0xFF);
let _local_5 = 0; if(saturation > 0)
let _local_6 = 0;
let _local_7 = 0;
if(_local_3 > 0)
{ {
_local_12 = 0; const t2 = lightness < 0.5 ? lightness * (1 + saturation) : (lightness + saturation) - (lightness * saturation);
_local_13 = 0; const t1 = (2 * lightness) - t2;
if(_local_4 < 0.5)
const rgb = [hue + (1 / 3), hue, hue - (1 / 3)].map(color =>
{ {
_local_12 = (_local_4 * (1 + _local_3)); if(color < 0) color += 1;
if(color > 1) color -= 1;
if(color * 6 < 1) return t1 + ((t2 - t1) * 6 * color);
if(color * 2 < 1) return t2;
if(color * 3 < 2) return t1 + ((t2 - t1) * ((2 / 3) - color) * 6);
return t1;
});
[red, green, blue] = rgb;
} }
else else
{ {
_local_12 = ((_local_4 + _local_3) - (_local_4 * _local_3)); red = green = blue = lightness; // In the case of no saturation, all colors are the same.
} }
_local_13 = ((2 * _local_4) - _local_12);
_local_14 = (_local_2 + (1 / 3)); const r = Math.round(red * 0xFF);
_local_15 = _local_2; const g = Math.round(green * 0xFF);
_local_16 = (_local_2 - (1 / 3)); const b = Math.round(blue * 0xFF);
if(_local_14 < 0)
{ return (r << 16) + (g << 8) + b;
_local_14 = (_local_14 + 1);
}
else
{
if(_local_14 > 1)
{
_local_14--;
}
}
if(_local_15 < 0)
{
_local_15 = (_local_15 + 1);
}
else
{
if(_local_15 > 1)
{
_local_15--;
}
}
if(_local_16 < 0)
{
_local_16 = (_local_16 + 1);
}
else
{
if(_local_16 > 1)
{
_local_16--;
}
}
if((_local_14 * 6) < 1)
{
_local_5 = (_local_13 + (((_local_12 - _local_13) * 6) * _local_14));
}
else
{
if((_local_14 * 2) < 1)
{
_local_5 = _local_12;
}
else
{
if((_local_14 * 3) < 2)
{
_local_5 = (_local_13 + (((_local_12 - _local_13) * 6) * ((2 / 3) - _local_14)));
}
else
{
_local_5 = _local_13;
}
}
}
if((_local_15 * 6) < 1)
{
_local_6 = (_local_13 + (((_local_12 - _local_13) * 6) * _local_15));
}
else
{
if((_local_15 * 2) < 1)
{
_local_6 = _local_12;
}
else
{
if((_local_15 * 3) < 2)
{
_local_6 = (_local_13 + (((_local_12 - _local_13) * 6) * ((2 / 3) - _local_15)));
}
else
{
_local_6 = _local_13;
}
}
}
if((_local_16 * 6) < 1)
{
_local_7 = (_local_13 + (((_local_12 - _local_13) * 6) * _local_16));
}
else
{
if((_local_16 * 2) < 1)
{
_local_7 = _local_12;
}
else
{
if((_local_16 * 3) < 2)
{
_local_7 = (_local_13 + (((_local_12 - _local_13) * 6) * ((2 / 3) - _local_16)));
}
else
{
_local_7 = _local_13;
}
}
}
}
else
{
_local_5 = _local_4;
_local_6 = _local_4;
_local_7 = _local_4;
}
const _local_8: number = Math.round((_local_5 * 0xFF));
const _local_9: number = Math.round((_local_6 * 0xFF));
const _local_10: number = Math.round((_local_7 * 0xFF));
const _local_11: number = (((_local_8 << 16) + (_local_9 << 8)) + _local_10);
return _local_11;
} }
public static rgb2xyz(k: number): IVector3D public static rgb2xyz(k: number): IVector3D

View File

@ -6,7 +6,9 @@ export const PrepareRenderer = async (options: Partial<AutoDetectOptions>): Prom
{ {
renderer = await autoDetectRenderer(options); renderer = await autoDetectRenderer(options);
renderer.events?.destroy();
return renderer; return renderer;
} };
export const GetRenderer = () => renderer; export const GetRenderer = () => renderer;

View File

@ -2,4 +2,8 @@ import { Container } from 'pixi.js';
const stage = new Container(); const stage = new Container();
stage.interactive = false;
stage.interactiveChildren = false;
stage.eventMode = 'none';
export const GetStage = () => stage; export const GetStage = () => stage;