You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-20 07:26:18 +00:00
🆙 Fix isometric rendering
This commit is contained in:
+26
-46
@@ -12,16 +12,30 @@ export class FurnitureGuildIsometricBadgeVisualization extends IsometricImageFur
|
|||||||
|
|
||||||
private _color1: number;
|
private _color1: number;
|
||||||
private _color2: number;
|
private _color2: number;
|
||||||
|
private _cachedAssetName: string;
|
||||||
|
|
||||||
|
constructor()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
|
||||||
|
this._cachedAssetName = null;
|
||||||
|
}
|
||||||
|
|
||||||
protected updateModel(scale: number): boolean
|
protected updateModel(scale: number): boolean
|
||||||
{
|
{
|
||||||
const flag = super.updateModel(scale);
|
const flag = super.updateModel(scale);
|
||||||
|
|
||||||
if(!this.hasThumbnailImage)
|
const assetName = this.object.model.getValue<string>(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_ASSET_NAME);
|
||||||
{
|
|
||||||
const assetName = this.object.model.getValue<string>(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_ASSET_NAME);
|
|
||||||
|
|
||||||
if(assetName && assetName.length) this.setThumbnailImages(this.getBitmapAsset(assetName));
|
if(assetName && assetName.length && assetName !== this._cachedAssetName)
|
||||||
|
{
|
||||||
|
const texture = this.getBitmapAsset(assetName);
|
||||||
|
|
||||||
|
if(texture)
|
||||||
|
{
|
||||||
|
this._cachedAssetName = assetName;
|
||||||
|
this.setThumbnailImages(texture);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const color1 = this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_COLOR_1);
|
const color1 = this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_COLOR_1);
|
||||||
@@ -37,9 +51,11 @@ export class FurnitureGuildIsometricBadgeVisualization extends IsometricImageFur
|
|||||||
|
|
||||||
protected generateTransformedThumbnail(texture: Texture, asset: IGraphicAsset): Texture
|
protected generateTransformedThumbnail(texture: Texture, asset: IGraphicAsset): Texture
|
||||||
{
|
{
|
||||||
const scale = 1.1;
|
const renderWidth = asset.width || 64;
|
||||||
|
const renderHeight = asset.height || renderWidth;
|
||||||
|
const difference = (renderWidth / texture.width);
|
||||||
|
const dScale = (renderHeight - 0.5 * renderWidth) / texture.height;
|
||||||
const matrix = new Matrix();
|
const matrix = new Matrix();
|
||||||
const difference = (asset.width / texture.width);
|
|
||||||
|
|
||||||
switch(this.direction)
|
switch(this.direction)
|
||||||
{
|
{
|
||||||
@@ -47,16 +63,16 @@ export class FurnitureGuildIsometricBadgeVisualization extends IsometricImageFur
|
|||||||
matrix.a = difference;
|
matrix.a = difference;
|
||||||
matrix.b = (-0.5 * difference);
|
matrix.b = (-0.5 * difference);
|
||||||
matrix.c = 0;
|
matrix.c = 0;
|
||||||
matrix.d = (difference * scale);
|
matrix.d = dScale;
|
||||||
matrix.tx = 0;
|
matrix.tx = 0;
|
||||||
matrix.ty = ((0.5 * difference) * texture.width);
|
matrix.ty = (0.5 * renderWidth);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
case 4:
|
case 4:
|
||||||
matrix.a = difference;
|
matrix.a = difference;
|
||||||
matrix.b = (0.5 * difference);
|
matrix.b = (0.5 * difference);
|
||||||
matrix.c = 0;
|
matrix.c = 0;
|
||||||
matrix.d = (difference * scale);
|
matrix.d = dScale;
|
||||||
matrix.tx = 0;
|
matrix.tx = 0;
|
||||||
matrix.ty = 0;
|
matrix.ty = 0;
|
||||||
break;
|
break;
|
||||||
@@ -69,43 +85,7 @@ export class FurnitureGuildIsometricBadgeVisualization extends IsometricImageFur
|
|||||||
matrix.ty = 0;
|
matrix.ty = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sprite = new Sprite(texture);
|
return TextureUtils.createAndWriteRenderTexture(renderWidth, renderHeight, new Sprite(texture), matrix);
|
||||||
|
|
||||||
sprite.setFromMatrix(matrix);
|
|
||||||
|
|
||||||
sprite.x = 0;
|
|
||||||
sprite.y = 0;
|
|
||||||
|
|
||||||
return TextureUtils.generateTexture(sprite);
|
|
||||||
|
|
||||||
/* const renderTexture = RenderTexture.create({
|
|
||||||
width: asset.width,
|
|
||||||
height: asset.height
|
|
||||||
});
|
|
||||||
|
|
||||||
PixiApplicationProxy.instance.renderer.render(sprite, {
|
|
||||||
renderTexture,
|
|
||||||
clear: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
return renderTexture; */
|
|
||||||
|
|
||||||
/* const sprite = new NitroSprite(texture);
|
|
||||||
|
|
||||||
const renderTexture = RenderTexture.create({
|
|
||||||
width: (asset.width + matrix.tx),
|
|
||||||
height: (asset.height + matrix.ty)
|
|
||||||
});
|
|
||||||
|
|
||||||
sprite.position.set(0)
|
|
||||||
|
|
||||||
PixiApplicationProxy.instance.renderer.render(sprite, {
|
|
||||||
renderTexture,
|
|
||||||
clear: true,
|
|
||||||
transform: matrix
|
|
||||||
});
|
|
||||||
|
|
||||||
return renderTexture; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getLayerColor(scale: number, layerId: number, colorId: number): number
|
protected getLayerColor(scale: number, layerId: number, colorId: number): number
|
||||||
|
|||||||
+2
-4
@@ -80,10 +80,8 @@ export class IsometricImageFurniVisualization extends FurnitureAnimatedVisualiza
|
|||||||
const asset = this.getAsset(assetName, layerId);
|
const asset = this.getAsset(assetName, layerId);
|
||||||
const thumbnailAssetName = `${this.getThumbnailAssetName(scale)}-${this._uniqueId}`;
|
const thumbnailAssetName = `${this.getThumbnailAssetName(scale)}-${this._uniqueId}`;
|
||||||
const transformedTexture = this.generateTransformedThumbnail(k, asset || { width: 64, height: 64 });
|
const transformedTexture = this.generateTransformedThumbnail(k, asset || { width: 64, height: 64 });
|
||||||
const sprite = new Sprite(transformedTexture);
|
const offsetX = asset ? asset.offsetX : -Math.floor(transformedTexture.width / 2);
|
||||||
const bounds = sprite.getLocalBounds();
|
const offsetY = asset ? asset.offsetY : -Math.floor(transformedTexture.height / 2);
|
||||||
const offsetX = -Math.floor(bounds.width / 2);
|
|
||||||
const offsetY = -Math.floor(bounds.height / 2);
|
|
||||||
|
|
||||||
this.asset.addAsset(thumbnailAssetName, transformedTexture, true, offsetX, offsetY, false, false);
|
this.asset.addAsset(thumbnailAssetName, transformedTexture, true, offsetX, offsetY, false, false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user