mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-27 01:40:52 +01:00
Updates
This commit is contained in:
parent
926d5f8085
commit
a445f91fdc
@ -16,7 +16,7 @@ export interface IAvatarImage extends IDisposable
|
|||||||
getLayerData(_arg_1: ISpriteDataContainer): IAnimationLayerData;
|
getLayerData(_arg_1: ISpriteDataContainer): IAnimationLayerData;
|
||||||
getImage(setType: string, hightlight: boolean, scale?: number, cache?: boolean): Texture;
|
getImage(setType: string, hightlight: boolean, scale?: number, cache?: boolean): Texture;
|
||||||
getImageAsSprite(setType: string, scale?: number): Sprite;
|
getImageAsSprite(setType: string, scale?: number): Sprite;
|
||||||
getCroppedImage(setType: string, scale?: number): Promise<HTMLImageElement>;
|
getCroppedImageUrl(setType: string, scale?: number): Promise<string>;
|
||||||
getAsset(_arg_1: string): IGraphicAsset;
|
getAsset(_arg_1: string): IGraphicAsset;
|
||||||
getDirection(): number;
|
getDirection(): number;
|
||||||
getFigure(): IAvatarFigureContainer;
|
getFigure(): IAvatarFigureContainer;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { AvatarAction, AvatarDirectionAngle, AvatarScaleType, AvatarSetType, IActionDefinition, IActiveActionData, IAdvancedMap, IAnimationLayerData, IAvatarDataContainer, IAvatarEffectListener, IAvatarFigureContainer, IAvatarImage, IGraphicAsset, IPartColor, ISpriteDataContainer } from '@nitrots/api';
|
import { AvatarAction, AvatarDirectionAngle, AvatarScaleType, AvatarSetType, IActionDefinition, IActiveActionData, IAnimationLayerData, IAvatarDataContainer, IAvatarEffectListener, IAvatarFigureContainer, IAvatarImage, IGraphicAsset, IPartColor, ISpriteDataContainer } from '@nitrots/api';
|
||||||
import { AdvancedMap, GetTickerTime, TextureUtils } from '@nitrots/utils';
|
import { GetRenderer, GetTickerTime, TextureUtils } from '@nitrots/utils';
|
||||||
import { ColorMatrixFilter, Container, Rectangle, RenderTexture, Sprite, Texture } from 'pixi.js';
|
import { ColorMatrixFilter, Container, Rectangle, RenderTexture, Sprite, Texture } from 'pixi.js';
|
||||||
import { AvatarFigureContainer } from './AvatarFigureContainer';
|
import { AvatarFigureContainer } from './AvatarFigureContainer';
|
||||||
import { AvatarStructure } from './AvatarStructure';
|
import { AvatarStructure } from './AvatarStructure';
|
||||||
@ -46,8 +46,6 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
|
|||||||
private _sortedActions: IActiveActionData[];
|
private _sortedActions: IActiveActionData[];
|
||||||
private _lastActionsString: string;
|
private _lastActionsString: string;
|
||||||
private _currentActionsString: string;
|
private _currentActionsString: string;
|
||||||
private _fullImageCache: IAdvancedMap<string, Texture>;
|
|
||||||
private _fullImageCacheSize: number = 5;
|
|
||||||
protected _isCachedImage: boolean = false;
|
protected _isCachedImage: boolean = false;
|
||||||
private _useFullImageCache: boolean = false;
|
private _useFullImageCache: boolean = false;
|
||||||
private _effectIdInUse: number = -1;
|
private _effectIdInUse: number = -1;
|
||||||
@ -86,7 +84,6 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
|
|||||||
this._defaultAction = new ActiveActionData(AvatarAction.POSTURE_STAND);
|
this._defaultAction = new ActiveActionData(AvatarAction.POSTURE_STAND);
|
||||||
this._defaultAction.definition = this._structure.getActionDefinition(AvatarImage.DEFAULT_ACTION);
|
this._defaultAction.definition = this._structure.getActionDefinition(AvatarImage.DEFAULT_ACTION);
|
||||||
this.resetActions();
|
this.resetActions();
|
||||||
this._fullImageCache = new AdvancedMap();
|
|
||||||
this._animationFrameCount = 0;
|
this._animationFrameCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,13 +118,6 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
|
|||||||
this._cache = null;
|
this._cache = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this._fullImageCache)
|
|
||||||
{
|
|
||||||
for(const k of this._fullImageCache.getValues()) (k && k.destroy());
|
|
||||||
|
|
||||||
this._fullImageCache = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._image = null;
|
this._image = null;
|
||||||
this._canvasOffsets = null;
|
this._canvasOffsets = null;
|
||||||
this._disposed = true;
|
this._disposed = true;
|
||||||
@ -534,7 +524,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
|
|||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getCroppedImage(setType: string, scale: number = 1): Promise<HTMLImageElement>
|
public async getCroppedImageUrl(setType: string, scale: number = 1): Promise<string>
|
||||||
{
|
{
|
||||||
if(!this._mainAction) return null;
|
if(!this._mainAction) return null;
|
||||||
|
|
||||||
@ -547,6 +537,13 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
|
|||||||
const setTypes = this.getBodyParts(setType, this._mainAction.definition.geometryType, this._mainDirection);
|
const setTypes = this.getBodyParts(setType, this._mainAction.definition.geometryType, this._mainDirection);
|
||||||
const container = new Container();
|
const container = new Container();
|
||||||
|
|
||||||
|
/* const sprite = new Sprite(Texture.EMPTY);
|
||||||
|
|
||||||
|
sprite.width = avatarCanvas.width;
|
||||||
|
sprite.height = avatarCanvas.height;
|
||||||
|
|
||||||
|
container.addChild(sprite); */
|
||||||
|
|
||||||
let partCount = (setTypes.length - 1);
|
let partCount = (setTypes.length - 1);
|
||||||
|
|
||||||
while(partCount >= 0)
|
while(partCount >= 0)
|
||||||
@ -593,10 +590,18 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
|
|||||||
partCount--;
|
partCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await TextureUtils.generateImage(TextureUtils.generateTexture({
|
const texture = TextureUtils.generateTexture({
|
||||||
target: container,
|
target: container,
|
||||||
frame: new Rectangle(0, 0, avatarCanvas.width, avatarCanvas.height)
|
frame: new Rectangle(0, 0, avatarCanvas.width, avatarCanvas.height)
|
||||||
}));
|
});
|
||||||
|
let canvas = GetRenderer().texture.generateCanvas(texture);
|
||||||
|
const base64 = canvas.toDataURL('image/png');
|
||||||
|
|
||||||
|
canvas = null;
|
||||||
|
|
||||||
|
texture.destroy(true);
|
||||||
|
|
||||||
|
return base64;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAsset(k: string): IGraphicAsset
|
public getAsset(k: string): IGraphicAsset
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { IAssetPlaneVisualizationLayer, IAssetRoomVisualizationData, IRoomGeometry, IRoomPlane, IVector3D } from '@nitrots/api';
|
import { IAssetPlaneVisualizationLayer, IAssetRoomVisualizationData, IRoomGeometry, IRoomPlane, IVector3D } from '@nitrots/api';
|
||||||
import { GetAssetManager } from '@nitrots/assets';
|
import { GetAssetManager } from '@nitrots/assets';
|
||||||
import { GetRenderer, PlaneMaskFilter, TextureUtils, Vector3d } from '@nitrots/utils';
|
import { GetRenderer, PlaneMaskFilter, TextureUtils, Vector3d } from '@nitrots/utils';
|
||||||
import { Container, Matrix, Point, Sprite, Texture, TilingSprite } from 'pixi.js';
|
import { Container, Filter, Matrix, Point, Sprite, Texture, TilingSprite } from 'pixi.js';
|
||||||
import { RoomGeometry } from '../../../utils';
|
import { RoomGeometry } from '../../../utils';
|
||||||
import { RoomPlaneBitmapMask } from './RoomPlaneBitmapMask';
|
import { RoomPlaneBitmapMask } from './RoomPlaneBitmapMask';
|
||||||
import { RoomPlaneRectangleMask } from './RoomPlaneRectangleMask';
|
import { RoomPlaneRectangleMask } from './RoomPlaneRectangleMask';
|
||||||
@ -59,6 +59,7 @@ export class RoomPlane implements IRoomPlane
|
|||||||
|
|
||||||
private _planeSprite: TilingSprite = null;
|
private _planeSprite: TilingSprite = null;
|
||||||
private _planeTexture: Texture = null;
|
private _planeTexture: Texture = null;
|
||||||
|
private _maskFilter: Filter = null;
|
||||||
|
|
||||||
constructor(origin: IVector3D, location: IVector3D, leftSide: IVector3D, rightSide: IVector3D, type: number, usesMask: boolean, secondaryNormals: IVector3D[], randomSeed: number, textureOffsetX: number = 0, textureOffsetY: number = 0, textureMaxX: number = 0, textureMaxY: number = 0)
|
constructor(origin: IVector3D, location: IVector3D, leftSide: IVector3D, rightSide: IVector3D, type: number, usesMask: boolean, secondaryNormals: IVector3D[], randomSeed: number, textureOffsetX: number = 0, textureOffsetY: number = 0, textureMaxX: number = 0, textureMaxY: number = 0)
|
||||||
{
|
{
|
||||||
@ -126,7 +127,12 @@ export class RoomPlane implements IRoomPlane
|
|||||||
|
|
||||||
let needsUpdate = false;
|
let needsUpdate = false;
|
||||||
|
|
||||||
if(this._geometryUpdateId !== geometry.updateId) needsUpdate = true;
|
if(this._geometryUpdateId !== geometry.updateId)
|
||||||
|
{
|
||||||
|
this._geometryUpdateId = geometry.updateId;
|
||||||
|
|
||||||
|
needsUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(!needsUpdate || !this._canBeVisible)
|
if(!needsUpdate || !this._canBeVisible)
|
||||||
{
|
{
|
||||||
@ -187,7 +193,6 @@ export class RoomPlane implements IRoomPlane
|
|||||||
|
|
||||||
this._relativeDepth = relativeDepth;
|
this._relativeDepth = relativeDepth;
|
||||||
this._isVisible = true;
|
this._isVisible = true;
|
||||||
this._geometryUpdateId = geometry.updateId;
|
|
||||||
|
|
||||||
Randomizer.setSeed(this._randomSeed);
|
Randomizer.setSeed(this._randomSeed);
|
||||||
|
|
||||||
@ -549,9 +554,9 @@ export class RoomPlane implements IRoomPlane
|
|||||||
|
|
||||||
this._maskChanged = false;
|
this._maskChanged = false;
|
||||||
|
|
||||||
container.filterArea = container.getBounds().rectangle;
|
if(!this._maskFilter) this._maskFilter = new PlaneMaskFilter({});
|
||||||
|
|
||||||
container.filters = [ new PlaneMaskFilter({}) ];
|
if(!container.filters) container.filters = [ this._maskFilter ];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user