mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-22 23:50:52 +01:00
Updates
This commit is contained in:
parent
8d7fc1e9b4
commit
1df42159a7
@ -1,5 +1,11 @@
|
||||
export class AvatarFigurePartType
|
||||
{
|
||||
public static MALE: string = 'M';
|
||||
public static FEMALE: string = 'F';
|
||||
public static UNISEX: string = 'U';
|
||||
public static SCALE: string = 'h';
|
||||
public static STD: string = 'std';
|
||||
public static DEFAULT_FRAME: number = 0;
|
||||
public static BODY: string = 'bd';
|
||||
public static SHOES: string = 'sh';
|
||||
public static LEGS: string = 'lg';
|
||||
|
@ -1,25 +1,25 @@
|
||||
export class FigureDataContainer
|
||||
{
|
||||
private static MALE: string = 'M';
|
||||
private static FEMALE: string = 'F';
|
||||
private static UNISEX: string = 'U';
|
||||
private static SCALE: string = 'h';
|
||||
private static STD: string = 'std';
|
||||
private static DEFAULT_FRAME: string = '0';
|
||||
private static HD: string = 'hd';
|
||||
private static HAIR: string = 'hr';
|
||||
private static HAT: string = 'ha';
|
||||
private static HEAD_ACCESSORIES: string = 'he';
|
||||
private static EYE_ACCESSORIES: string = 'ea';
|
||||
private static FACE_ACCESSORIES: string = 'fa';
|
||||
private static JACKET: string = 'cc';
|
||||
private static SHIRT: string = 'ch';
|
||||
private static CHEST_ACCESSORIES: string = 'ca';
|
||||
private static CHEST_PRINTS: string = 'cp';
|
||||
private static TROUSERS: string = 'lg';
|
||||
private static SHOES: string = 'sh';
|
||||
private static TROUSER_ACCESSORIES: string = 'wa';
|
||||
private static BLOCKED_FX_TYPES: number[] = [28, 29, 30, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 68];
|
||||
public static MALE: string = 'M';
|
||||
public static FEMALE: string = 'F';
|
||||
public static UNISEX: string = 'U';
|
||||
public static SCALE: string = 'h';
|
||||
public static STD: string = 'std';
|
||||
public static DEFAULT_FRAME: string = '0';
|
||||
public static HD: string = 'hd';
|
||||
public static HAIR: string = 'hr';
|
||||
public static HAT: string = 'ha';
|
||||
public static HEAD_ACCESSORIES: string = 'he';
|
||||
public static EYE_ACCESSORIES: string = 'ea';
|
||||
public static FACE_ACCESSORIES: string = 'fa';
|
||||
public static JACKET: string = 'cc';
|
||||
public static SHIRT: string = 'ch';
|
||||
public static CHEST_ACCESSORIES: string = 'ca';
|
||||
public static CHEST_PRINTS: string = 'cp';
|
||||
public static TROUSERS: string = 'lg';
|
||||
public static SHOES: string = 'sh';
|
||||
public static TROUSER_ACCESSORIES: string = 'wa';
|
||||
public static BLOCKED_FX_TYPES: number[] = [28, 29, 30, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 68];
|
||||
|
||||
private _data: Map<string, number>;
|
||||
private _colors: Map<string, number[]>;
|
||||
|
@ -11,6 +11,7 @@
|
||||
"main": "./index",
|
||||
"dependencies": {
|
||||
"@nitrots/api": "1.0.0",
|
||||
"@nitrots/assets": "1.0.0",
|
||||
"@nitrots/configuration": "1.0.0",
|
||||
"@nitrots/eslint-config": "1.0.0",
|
||||
"@nitrots/events": "1.0.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { AlphaTolerance } from '@nitrots/api';
|
||||
import { GetRenderer } from '@nitrots/utils';
|
||||
import { GlRenderTarget, Point, Sprite, Texture, TextureSource, WebGLRenderer } from 'pixi.js';
|
||||
import { GetRenderer, TextureUtils } from '@nitrots/utils';
|
||||
import { GlRenderTarget, Point, RendererType, Sprite, Texture, TextureSource, WebGPURenderer } from 'pixi.js';
|
||||
|
||||
const BYTES_PER_PIXEL = 4;
|
||||
|
||||
@ -56,7 +56,9 @@ export class ExtendedSprite extends Sprite
|
||||
if((!textureSource || !textureSource.hitMap) && !ExtendedSprite.generateHitMapForTextureSource(textureSource)) return false;
|
||||
|
||||
//@ts-ignore
|
||||
const hitMap = (textureSource.hitMap as U8intclampedArray);
|
||||
const hitMap = (textureSource.hitMap as Uint8Array);
|
||||
|
||||
if(!hitMap) return false;
|
||||
|
||||
let dx = (point.x + texture.frame.x);
|
||||
let dy = (point.y + texture.frame.y);
|
||||
@ -79,28 +81,40 @@ export class ExtendedSprite extends Sprite
|
||||
{
|
||||
if(!textureSource) return false;
|
||||
|
||||
const renderer = GetRenderer();
|
||||
const width = Math.max(Math.round(textureSource.width * textureSource.resolution), 1);
|
||||
const height = Math.max(Math.round(textureSource.height * textureSource.resolution), 1);
|
||||
const pixels = new Uint8Array(BYTES_PER_PIXEL * width * height);
|
||||
|
||||
const renderer = GetRenderer() as WebGLRenderer;
|
||||
let pixels: Uint8ClampedArray = null;
|
||||
|
||||
const renderTarget = renderer.renderTarget.getRenderTarget(textureSource);
|
||||
const glRenterTarget = renderer.renderTarget.getGpuRenderTarget(renderTarget) as GlRenderTarget;
|
||||
if(renderer instanceof WebGPURenderer)
|
||||
{
|
||||
pixels = TextureUtils.getPixels(new Texture(textureSource))?.pixels ?? null;
|
||||
}
|
||||
|
||||
const gl = renderer.gl;
|
||||
else if(renderer.type === RendererType.WEBGL)
|
||||
{
|
||||
pixels = new Uint8ClampedArray(BYTES_PER_PIXEL * width * height);
|
||||
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, glRenterTarget.resolveTargetFramebuffer);
|
||||
const renderTarget = renderer.renderTarget.getRenderTarget(textureSource);
|
||||
const glRenderTarget = renderer.renderTarget.getGpuRenderTarget(renderTarget) as GlRenderTarget;
|
||||
|
||||
gl.readPixels(
|
||||
0,
|
||||
0,
|
||||
width,
|
||||
height,
|
||||
gl.RGBA,
|
||||
gl.UNSIGNED_BYTE,
|
||||
pixels
|
||||
);
|
||||
const gl = renderer.gl;
|
||||
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, glRenderTarget.resolveTargetFramebuffer);
|
||||
|
||||
gl.readPixels(
|
||||
0,
|
||||
0,
|
||||
width,
|
||||
height,
|
||||
gl.RGBA,
|
||||
gl.UNSIGNED_BYTE,
|
||||
pixels
|
||||
);
|
||||
}
|
||||
|
||||
if(!pixels) return false;
|
||||
|
||||
//@ts-ignore
|
||||
textureSource.hitMap = pixels;
|
||||
|
Loading…
Reference in New Issue
Block a user