mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-22 23:50:52 +01:00
More room plane updates
This commit is contained in:
parent
f5d617f092
commit
17bc510b4f
@ -247,13 +247,6 @@ export class RoomPlane implements IRoomPlane
|
|||||||
|
|
||||||
public dispose(): void
|
public dispose(): void
|
||||||
{
|
{
|
||||||
if(this._bitmapData)
|
|
||||||
{
|
|
||||||
this._bitmapData.destroy(true);
|
|
||||||
|
|
||||||
this._bitmapData = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._activeTexture = null;
|
this._activeTexture = null;
|
||||||
this._location = null;
|
this._location = null;
|
||||||
this._origin = null;
|
this._origin = null;
|
||||||
@ -801,7 +794,7 @@ export class RoomPlane implements IRoomPlane
|
|||||||
this._maskBitmapData = null;
|
this._maskBitmapData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._maskBitmapData = this._textureCache.createAndFillRenderTexture(width, height);
|
this._maskBitmapData = this._textureCache.createAndFillRenderTexture(width, height, 'mask');
|
||||||
this._maskChanged = true;
|
this._maskChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,14 +7,12 @@ import { AnimationItem } from './AnimationItem';
|
|||||||
export class PlaneVisualizationAnimationLayer implements IDisposable
|
export class PlaneVisualizationAnimationLayer implements IDisposable
|
||||||
{
|
{
|
||||||
private _color: number = 0;
|
private _color: number = 0;
|
||||||
private _bitmapData: RenderTexture = null;
|
|
||||||
private _isDisposed: boolean = false;
|
private _isDisposed: boolean = false;
|
||||||
private _items: AnimationItem[];
|
private _items: AnimationItem[];
|
||||||
|
|
||||||
constructor(k: any, assets: IGraphicAssetCollection)
|
constructor(k: any, assets: IGraphicAssetCollection)
|
||||||
{
|
{
|
||||||
this._color = 0;
|
this._color = 0;
|
||||||
this._bitmapData = null;
|
|
||||||
this._isDisposed = false;
|
this._isDisposed = false;
|
||||||
this._items = [];
|
this._items = [];
|
||||||
|
|
||||||
@ -45,13 +43,6 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
|
|||||||
{
|
{
|
||||||
this._isDisposed = true;
|
this._isDisposed = true;
|
||||||
|
|
||||||
if(this._bitmapData)
|
|
||||||
{
|
|
||||||
this._bitmapData.destroy();
|
|
||||||
|
|
||||||
this._bitmapData = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this._items)
|
if(this._items)
|
||||||
{
|
{
|
||||||
for(const item of this._items) item && item.dispose();
|
for(const item of this._items) item && item.dispose();
|
||||||
@ -62,32 +53,10 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
|
|||||||
|
|
||||||
public clearCache(): void
|
public clearCache(): void
|
||||||
{
|
{
|
||||||
if(this._bitmapData)
|
|
||||||
{
|
|
||||||
this._bitmapData.destroy(true);
|
|
||||||
|
|
||||||
this._bitmapData = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(textureCache: PlaneTextureCache, canvas: RenderTexture, width: number, height: number, normal: IVector3D, offsetX: number, offsetY: number, maxX: number, maxY: number, dimensionX: number, dimensionY: number, timeSinceStartMs: number): RenderTexture
|
public render(textureCache: PlaneTextureCache, canvas: RenderTexture, width: number, height: number, normal: IVector3D, offsetX: number, offsetY: number, maxX: number, maxY: number, dimensionX: number, dimensionY: number, timeSinceStartMs: number): RenderTexture
|
||||||
{
|
{
|
||||||
/* if(!canvas || (canvas.width !== width) || (canvas.height !== height))
|
|
||||||
{
|
|
||||||
if(!this._bitmapData || (this._bitmapData.width !== width) || (this._bitmapData.height !== height))
|
|
||||||
{
|
|
||||||
if(this._bitmapData) this._bitmapData.destroy(true);
|
|
||||||
|
|
||||||
this._bitmapData = textureCache.createRenderTexture(width, height);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
textureCache.clearRenderTexture(this._bitmapData);
|
|
||||||
}
|
|
||||||
|
|
||||||
canvas = this._bitmapData;
|
|
||||||
} */
|
|
||||||
|
|
||||||
if(((maxX > 0) && (maxY > 0)))
|
if(((maxX > 0) && (maxY > 0)))
|
||||||
{
|
{
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
@ -7,7 +7,6 @@ import { PlaneTexture } from './PlaneTexture';
|
|||||||
|
|
||||||
export class PlaneMaterialCell
|
export class PlaneMaterialCell
|
||||||
{
|
{
|
||||||
private _cachedSprite: Sprite;
|
|
||||||
private _texture: PlaneTexture;
|
private _texture: PlaneTexture;
|
||||||
private _extraItemOffsets: Point[];
|
private _extraItemOffsets: Point[];
|
||||||
private _extraItemAssets: IGraphicAsset[];
|
private _extraItemAssets: IGraphicAsset[];
|
||||||
@ -15,7 +14,6 @@ export class PlaneMaterialCell
|
|||||||
|
|
||||||
constructor(texture: PlaneTexture, assets: IGraphicAsset[] = null, offsetPoints: Point[] = null, limit: number = 0)
|
constructor(texture: PlaneTexture, assets: IGraphicAsset[] = null, offsetPoints: Point[] = null, limit: number = 0)
|
||||||
{
|
{
|
||||||
this._cachedSprite = null;
|
|
||||||
this._texture = texture;
|
this._texture = texture;
|
||||||
this._extraItemOffsets = [];
|
this._extraItemOffsets = [];
|
||||||
this._extraItemAssets = [];
|
this._extraItemAssets = [];
|
||||||
@ -69,13 +67,6 @@ export class PlaneMaterialCell
|
|||||||
this._texture = null;
|
this._texture = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this._cachedSprite)
|
|
||||||
{
|
|
||||||
this._cachedSprite.destroy();
|
|
||||||
|
|
||||||
this._cachedSprite = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._extraItemAssets = null;
|
this._extraItemAssets = null;
|
||||||
this._extraItemOffsets = null;
|
this._extraItemOffsets = null;
|
||||||
this._extraItemCount = 0;
|
this._extraItemCount = 0;
|
||||||
@ -83,12 +74,6 @@ export class PlaneMaterialCell
|
|||||||
|
|
||||||
public clearCache(): void
|
public clearCache(): void
|
||||||
{
|
{
|
||||||
if(this._cachedSprite)
|
|
||||||
{
|
|
||||||
this._cachedSprite.destroy();
|
|
||||||
|
|
||||||
this._cachedSprite = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeight(normal: IVector3D): number
|
public getHeight(normal: IVector3D): number
|
||||||
@ -138,10 +123,6 @@ export class PlaneMaterialCell
|
|||||||
|
|
||||||
if(!this.isStatic)
|
if(!this.isStatic)
|
||||||
{
|
{
|
||||||
if(this._cachedSprite) this._cachedSprite.destroy();
|
|
||||||
|
|
||||||
this._cachedSprite = bitmap;
|
|
||||||
|
|
||||||
const limitMin = Math.min(this._extraItemCount, this._extraItemOffsets.length);
|
const limitMin = Math.min(this._extraItemCount, this._extraItemOffsets.length);
|
||||||
const limitMax = Math.max(this._extraItemCount, this._extraItemOffsets.length);
|
const limitMax = Math.max(this._extraItemCount, this._extraItemOffsets.length);
|
||||||
const offsetIndexes = Randomizer.getArray(this._extraItemCount, limitMax);
|
const offsetIndexes = Randomizer.getArray(this._extraItemCount, limitMax);
|
||||||
@ -194,14 +175,12 @@ export class PlaneMaterialCell
|
|||||||
|
|
||||||
sprite.transform.setFromMatrix(flipMatrix);
|
sprite.transform.setFromMatrix(flipMatrix);
|
||||||
|
|
||||||
this._cachedSprite.addChild(sprite);
|
bitmap.addChild(sprite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._cachedSprite;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
|
@ -83,12 +83,7 @@ export class PlaneMaterialCellColumn
|
|||||||
this._cells = null;
|
this._cells = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this._cachedBitmapData)
|
this._cachedBitmapData = null;
|
||||||
{
|
|
||||||
this._cachedBitmapData.destroy(true);
|
|
||||||
|
|
||||||
this._cachedBitmapData = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this._cachedBitmapNormal) this._cachedBitmapNormal = null;
|
if(this._cachedBitmapNormal) this._cachedBitmapNormal = null;
|
||||||
}
|
}
|
||||||
@ -97,12 +92,7 @@ export class PlaneMaterialCellColumn
|
|||||||
{
|
{
|
||||||
if(!this._isCached) return;
|
if(!this._isCached) return;
|
||||||
|
|
||||||
if(this._cachedBitmapData)
|
if(this._cachedBitmapData) this._cachedBitmapData = null;
|
||||||
{
|
|
||||||
this._cachedBitmapData.destroy(true);
|
|
||||||
|
|
||||||
this._cachedBitmapData = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this._cachedBitmapNormal)
|
if(this._cachedBitmapNormal)
|
||||||
{
|
{
|
||||||
|
@ -99,13 +99,6 @@ export class PlaneMaterialCellMatrix
|
|||||||
|
|
||||||
public dispose(): void
|
public dispose(): void
|
||||||
{
|
{
|
||||||
if(this._cachedBitmapData)
|
|
||||||
{
|
|
||||||
this._cachedBitmapData.destroy(true);
|
|
||||||
|
|
||||||
this._cachedBitmapData = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this._cachedBitmapNormal) this._cachedBitmapNormal = null;
|
if(this._cachedBitmapNormal) this._cachedBitmapNormal = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,13 +106,6 @@ export class PlaneMaterialCellMatrix
|
|||||||
{
|
{
|
||||||
if(!this._isCached) return;
|
if(!this._isCached) return;
|
||||||
|
|
||||||
if(this._cachedBitmapData)
|
|
||||||
{
|
|
||||||
this._cachedBitmapData.destroy();
|
|
||||||
|
|
||||||
this._cachedBitmapData = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this._cachedBitmapNormal)
|
if(this._cachedBitmapNormal)
|
||||||
{
|
{
|
||||||
this._cachedBitmapNormal.x = 0;
|
this._cachedBitmapNormal.x = 0;
|
||||||
@ -168,7 +154,7 @@ export class PlaneMaterialCellMatrix
|
|||||||
{
|
{
|
||||||
if(this._cachedBitmapData)
|
if(this._cachedBitmapData)
|
||||||
{
|
{
|
||||||
if((this._cachedBitmapData.width === width) && (this._cachedBitmapData.height === height) && Vector3d.isEqual(this._cachedBitmapNormal, normal))
|
if(this._cachedBitmapData.baseTexture && (this._cachedBitmapData.width === width) && (this._cachedBitmapData.height === height) && Vector3d.isEqual(this._cachedBitmapNormal, normal))
|
||||||
{
|
{
|
||||||
if(canvas)
|
if(canvas)
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,6 @@ export class PlaneVisualization
|
|||||||
{
|
{
|
||||||
private _layers: IDisposable[];
|
private _layers: IDisposable[];
|
||||||
private _geometry: IRoomGeometry;
|
private _geometry: IRoomGeometry;
|
||||||
private _cachedBitmapData: RenderTexture;
|
|
||||||
private _cachedBitmapNormal: Vector3d;
|
private _cachedBitmapNormal: Vector3d;
|
||||||
private _isCached: boolean;
|
private _isCached: boolean;
|
||||||
private _hasAnimationLayers: boolean;
|
private _hasAnimationLayers: boolean;
|
||||||
@ -18,7 +17,6 @@ export class PlaneVisualization
|
|||||||
{
|
{
|
||||||
this._layers = [];
|
this._layers = [];
|
||||||
this._geometry = geometry;
|
this._geometry = geometry;
|
||||||
this._cachedBitmapData = null;
|
|
||||||
this._cachedBitmapNormal = new Vector3d();
|
this._cachedBitmapNormal = new Vector3d();
|
||||||
this._isCached = false;
|
this._isCached = false;
|
||||||
this._hasAnimationLayers = false;
|
this._hasAnimationLayers = false;
|
||||||
@ -61,13 +59,6 @@ export class PlaneVisualization
|
|||||||
|
|
||||||
this._geometry = null;
|
this._geometry = null;
|
||||||
|
|
||||||
if(this._cachedBitmapData)
|
|
||||||
{
|
|
||||||
this._cachedBitmapData.destroy();
|
|
||||||
|
|
||||||
this._cachedBitmapData = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this._cachedBitmapNormal) this._cachedBitmapNormal = null;
|
if(this._cachedBitmapNormal) this._cachedBitmapNormal = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,13 +66,6 @@ export class PlaneVisualization
|
|||||||
{
|
{
|
||||||
if(!this._isCached) return;
|
if(!this._isCached) return;
|
||||||
|
|
||||||
if(this._cachedBitmapData)
|
|
||||||
{
|
|
||||||
this._cachedBitmapData.destroy();
|
|
||||||
|
|
||||||
this._cachedBitmapData = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this._cachedBitmapNormal)
|
if(this._cachedBitmapNormal)
|
||||||
{
|
{
|
||||||
this._cachedBitmapNormal.assign(new Vector3d());
|
this._cachedBitmapNormal.assign(new Vector3d());
|
||||||
@ -146,31 +130,9 @@ export class PlaneVisualization
|
|||||||
|
|
||||||
if((!canvas || (canvas.width !== width)) || (canvas.height !== height)) canvas = null;
|
if((!canvas || (canvas.width !== width)) || (canvas.height !== height)) canvas = null;
|
||||||
|
|
||||||
/* if(this._cachedBitmapData)
|
|
||||||
{
|
|
||||||
if((this._cachedBitmapData.width === width) && (this._cachedBitmapData.height === height) && (Vector3d.isEqual(this._cachedBitmapNormal, normal)))
|
|
||||||
{
|
|
||||||
if(!this.hasAnimationLayers)
|
|
||||||
{
|
|
||||||
if(canvas)
|
|
||||||
{
|
|
||||||
textureCache.writeToRenderTexture(new Sprite(this._cachedBitmapData), canvas, true);
|
|
||||||
|
|
||||||
return canvas;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this._cachedBitmapData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this._cachedBitmapData = null;
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
this._isCached = true;
|
this._isCached = true;
|
||||||
|
|
||||||
this._cachedBitmapData = textureCache.createAndFillRenderTexture(width, height, planeId);
|
const bitmap = textureCache.createAndFillRenderTexture(width, height, planeId);
|
||||||
|
|
||||||
this._cachedBitmapNormal.assign(normal);
|
this._cachedBitmapNormal.assign(normal);
|
||||||
|
|
||||||
@ -182,16 +144,16 @@ export class PlaneVisualization
|
|||||||
|
|
||||||
if(layer instanceof PlaneVisualizationLayer)
|
if(layer instanceof PlaneVisualizationLayer)
|
||||||
{
|
{
|
||||||
layer.render(planeId, textureCache, this._cachedBitmapData, width, height, normal, useTexture, offsetX, offsetY);
|
layer.render(`${ planeId }:${ this._layers.indexOf(layer) }`, textureCache, bitmap, width, height, normal, useTexture, offsetX, offsetY);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(layer instanceof PlaneVisualizationAnimationLayer)
|
else if(layer instanceof PlaneVisualizationAnimationLayer)
|
||||||
{
|
{
|
||||||
layer.render(textureCache, this._cachedBitmapData, width, height, normal, offsetX, offsetY, maxX, maxY, dimensionX, dimensionY, timeSinceStartMs);
|
layer.render(textureCache, bitmap, width, height, normal, offsetX, offsetY, maxX, maxY, dimensionX, dimensionY, timeSinceStartMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._cachedBitmapData;
|
return bitmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ export class PlaneVisualizationLayer
|
|||||||
private _color: number;
|
private _color: number;
|
||||||
private _offset: number;
|
private _offset: number;
|
||||||
private _align: number;
|
private _align: number;
|
||||||
private _bitmapData: RenderTexture;
|
|
||||||
private _isDisposed: boolean;
|
private _isDisposed: boolean;
|
||||||
|
|
||||||
constructor(material: PlaneMaterial, color: number, align: number, offset: number = 0)
|
constructor(material: PlaneMaterial, color: number, align: number, offset: number = 0)
|
||||||
@ -24,7 +23,6 @@ export class PlaneVisualizationLayer
|
|||||||
this._offset = offset;
|
this._offset = offset;
|
||||||
this._align = align;
|
this._align = align;
|
||||||
this._color = color;
|
this._color = color;
|
||||||
this._bitmapData = null;
|
|
||||||
this._isDisposed = false;
|
this._isDisposed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,12 +51,6 @@ export class PlaneVisualizationLayer
|
|||||||
|
|
||||||
public clearCache(): void
|
public clearCache(): void
|
||||||
{
|
{
|
||||||
if(this._bitmapData)
|
|
||||||
{
|
|
||||||
this._bitmapData.destroy(true);
|
|
||||||
|
|
||||||
this._bitmapData = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(planeId: string, textureCache: PlaneTextureCache, canvas: RenderTexture, width: number, height: number, normal: IVector3D, useTexture: boolean, offsetX: number, offsetY: number): RenderTexture
|
public render(planeId: string, textureCache: PlaneTextureCache, canvas: RenderTexture, width: number, height: number, normal: IVector3D, useTexture: boolean, offsetX: number, offsetY: number): RenderTexture
|
||||||
|
@ -14,12 +14,7 @@ export class PlaneTextureCache
|
|||||||
|
|
||||||
public clearCache(): void
|
public clearCache(): void
|
||||||
{
|
{
|
||||||
const previousTextures = this.RENDER_TEXTURE_CACHE.slice();
|
this.RENDER_TEXTURE_POOL.forEach(renderTexture => renderTexture?.destroy(true));
|
||||||
|
|
||||||
setTimeout(() =>
|
|
||||||
{
|
|
||||||
previousTextures.forEach(renderTexture => renderTexture?.destroy(true));
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
this.RENDER_TEXTURE_POOL.clear();
|
this.RENDER_TEXTURE_POOL.clear();
|
||||||
this.RENDER_TEXTURE_CACHE = [];
|
this.RENDER_TEXTURE_CACHE = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user