You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-20 15:36:18 +00:00
🆙 Fixed the WallItems with color background
This commit is contained in:
@@ -144,8 +144,7 @@ export class SizeData
|
|||||||
|
|
||||||
if(layerId < 0 || (layerId >= this._layerCount)) return false;
|
if(layerId < 0 || (layerId >= this._layerCount)) return false;
|
||||||
|
|
||||||
// TODO: check the .nitro files for inks
|
if(layer.ink !== undefined) directionData.setLayerBlendMode(layerId, this.parseLayerBlendMode(layer.ink));
|
||||||
if(layer.ink !== undefined) directionData.setLayerBlendMode(layerId, (layer.ink?.toLowerCase() as BLEND_MODES));
|
|
||||||
|
|
||||||
if(layer.tag !== undefined) directionData.setLayerTag(layerId, layer.tag);
|
if(layer.tag !== undefined) directionData.setLayerTag(layerId, layer.tag);
|
||||||
|
|
||||||
@@ -163,6 +162,28 @@ export class SizeData
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private parseLayerBlendMode(ink: string | number): BLEND_MODES
|
||||||
|
{
|
||||||
|
if(typeof ink === 'number')
|
||||||
|
{
|
||||||
|
if(ink === 33) return 'add';
|
||||||
|
|
||||||
|
return LayerData.DEFAULT_BLEND_MODE;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(ink.toUpperCase())
|
||||||
|
{
|
||||||
|
case 'ADD':
|
||||||
|
return 'add';
|
||||||
|
case 'SUBTRACT':
|
||||||
|
return 'subtract';
|
||||||
|
case 'DARKEN':
|
||||||
|
return 'darken';
|
||||||
|
default:
|
||||||
|
return LayerData.DEFAULT_BLEND_MODE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public getValidDirection(direction: number): number
|
public getValidDirection(direction: number): number
|
||||||
{
|
{
|
||||||
const existing = this._directions.get(direction);
|
const existing = this._directions.get(direction);
|
||||||
|
|||||||
+27
-2
@@ -4,8 +4,9 @@ import { FurnitureBrandedImageVisualization } from './FurnitureBrandedImageVisua
|
|||||||
|
|
||||||
export class FurnitureRoomBackgroundVisualization extends FurnitureBrandedImageVisualization
|
export class FurnitureRoomBackgroundVisualization extends FurnitureBrandedImageVisualization
|
||||||
{
|
{
|
||||||
private _imageOffset: DirectionalOffsetData;
|
private static readonly BRANDED_IMAGE_LAYER_DEPTH_BIAS: number = 0.01;
|
||||||
|
|
||||||
|
private _imageOffset: DirectionalOffsetData;
|
||||||
protected imageReady(texture: Texture, imageUrl: string): void
|
protected imageReady(texture: Texture, imageUrl: string): void
|
||||||
{
|
{
|
||||||
super.imageReady(texture, imageUrl);
|
super.imageReady(texture, imageUrl);
|
||||||
@@ -52,9 +53,33 @@ export class FurnitureRoomBackgroundVisualization extends FurnitureBrandedImageV
|
|||||||
return super.getLayerYOffset(scale, direction, layerId) + this._offsetY;
|
return super.getLayerYOffset(scale, direction, layerId) + this._offsetY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected getLayerAlpha(scale: number, direction: number, layerId: number): number
|
||||||
|
{
|
||||||
|
let alpha = super.getLayerAlpha(scale, direction, layerId);
|
||||||
|
|
||||||
|
if(this.shouldSuppressInkLayer(scale, direction, layerId)) alpha = 0;
|
||||||
|
|
||||||
|
return alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
private shouldSuppressInkLayer(scale: number, direction: number, layerId: number): boolean
|
||||||
|
{
|
||||||
|
if(this.getLayerTag(scale, direction, layerId) === FurnitureBrandedImageVisualization.BRANDED_IMAGE) return false;
|
||||||
|
|
||||||
|
return (this.getLayerBlendMode(scale, direction, layerId) !== 'normal');
|
||||||
|
}
|
||||||
|
|
||||||
protected getLayerZOffset(scale: number, direction: number, layerId: number): number
|
protected getLayerZOffset(scale: number, direction: number, layerId: number): number
|
||||||
{
|
{
|
||||||
return super.getLayerZOffset(scale, direction, layerId) + (-(this._offsetZ));
|
let zOffset = (super.getLayerZOffset(scale, direction, layerId) + (-(this._offsetZ)));
|
||||||
|
|
||||||
|
if(this.getLayerTag(scale, direction, layerId) === FurnitureBrandedImageVisualization.BRANDED_IMAGE)
|
||||||
|
{
|
||||||
|
zOffset += FurnitureRoomBackgroundVisualization.BRANDED_IMAGE_LAYER_DEPTH_BIAS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return zOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getLayerIgnoreMouse(scale: number, direction: number, layerId: number): boolean
|
protected getLayerIgnoreMouse(scale: number, direction: number, layerId: number): boolean
|
||||||
|
|||||||
@@ -319,6 +319,7 @@ export class FurnitureVisualization extends RoomObjectSpriteVisualization
|
|||||||
sprite.offsetX = assetData.offsetX;
|
sprite.offsetX = assetData.offsetX;
|
||||||
sprite.offsetY = (assetData.offsetY + this.getLayerYOffset(scale, this._direction, layerId));
|
sprite.offsetY = (assetData.offsetY + this.getLayerYOffset(scale, this._direction, layerId));
|
||||||
sprite.alpha = (48 * this._alphaMultiplier);
|
sprite.alpha = (48 * this._alphaMultiplier);
|
||||||
|
|
||||||
sprite.alphaTolerance = AlphaTolerance.MATCH_NOTHING;
|
sprite.alphaTolerance = AlphaTolerance.MATCH_NOTHING;
|
||||||
|
|
||||||
relativeDepth = 1;
|
relativeDepth = 1;
|
||||||
@@ -463,11 +464,50 @@ export class FurnitureVisualization extends RoomObjectSpriteVisualization
|
|||||||
|
|
||||||
if(this._alphaMultiplier !== null) alpha = (alpha * this._alphaMultiplier);
|
if(this._alphaMultiplier !== null) alpha = (alpha * this._alphaMultiplier);
|
||||||
|
|
||||||
|
if(this.shouldSuppressBackgroundMatteLayer(scale, direction, layerId, alpha)) alpha = 0;
|
||||||
|
|
||||||
this._spriteAlphas[layerId] = alpha;
|
this._spriteAlphas[layerId] = alpha;
|
||||||
|
|
||||||
return alpha;
|
return alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private shouldSuppressBackgroundMatteLayer(scale: number, direction: number, layerId: number, alpha: number): boolean
|
||||||
|
{
|
||||||
|
if((layerId < 0) || (alpha <= 0)) return false;
|
||||||
|
|
||||||
|
const state = this.object?.getState?.(0) ?? 0;
|
||||||
|
|
||||||
|
if(state === 0 || this.isBackgroundColorBlack()) return false;
|
||||||
|
|
||||||
|
const totalLayers = Math.max((this._layerCount - this.getAdditionalLayerCount()), 0);
|
||||||
|
|
||||||
|
if(totalLayers < 3) return false;
|
||||||
|
|
||||||
|
if(!this.getLayerIgnoreMouse(scale, direction, layerId)) return false;
|
||||||
|
|
||||||
|
if(this.getLayerBlendMode(scale, direction, layerId) === 'normal') return false;
|
||||||
|
|
||||||
|
if(layerId !== (totalLayers - 1)) return false;
|
||||||
|
|
||||||
|
if(this.getLayerBlendMode(scale, direction, 0) !== 'normal') return false;
|
||||||
|
|
||||||
|
return (this.getLayerBlendMode(scale, direction, 1) !== 'normal');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private isBackgroundColorBlack(): boolean
|
||||||
|
{
|
||||||
|
const model = this.object?.model;
|
||||||
|
|
||||||
|
if(!model) return false;
|
||||||
|
|
||||||
|
const lightness = model.getValue<number>(RoomObjectVariable.FURNITURE_ROOM_BACKGROUND_COLOR_LIGHTNESS);
|
||||||
|
|
||||||
|
if(lightness === undefined || lightness === null) return false;
|
||||||
|
|
||||||
|
return (lightness <= 0);
|
||||||
|
}
|
||||||
|
|
||||||
protected getLayerColor(scale: number, layerId: number, colorId: number): number
|
protected getLayerColor(scale: number, layerId: number, colorId: number): number
|
||||||
{
|
{
|
||||||
const existing = this._spriteColors[layerId];
|
const existing = this._spriteColors[layerId];
|
||||||
|
|||||||
Reference in New Issue
Block a user