mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-26 17:30:52 +01:00
Fix texture cache
This commit is contained in:
parent
7857440d3e
commit
efb2103e97
@ -2,7 +2,7 @@ import { Renderer, RenderTexture, Resource, Texture } from '@pixi/core';
|
|||||||
import { Matrix, Point } from '@pixi/math';
|
import { Matrix, Point } from '@pixi/math';
|
||||||
import { Sprite } from '@pixi/sprite';
|
import { Sprite } from '@pixi/sprite';
|
||||||
import { IRoomGeometry, IRoomPlane, IVector3D, Vector3d } from '../../../../../api';
|
import { IRoomGeometry, IRoomPlane, IVector3D, Vector3d } from '../../../../../api';
|
||||||
import { PixiApplicationProxy, RoomTextureUtils, TextureUtils } from '../../../../../pixi-proxy';
|
import { PixiApplicationProxy, RoomTextureCache } from '../../../../../pixi-proxy';
|
||||||
import { ColorConverter } from '../../../../../room';
|
import { ColorConverter } from '../../../../../room';
|
||||||
import { PlaneMaskManager } from './mask';
|
import { PlaneMaskManager } from './mask';
|
||||||
import { PlaneDrawingData } from './PlaneDrawingData';
|
import { PlaneDrawingData } from './PlaneDrawingData';
|
||||||
@ -20,6 +20,7 @@ export class RoomPlane implements IRoomPlane
|
|||||||
public static TYPE_LANDSCAPE: number = 3;
|
public static TYPE_LANDSCAPE: number = 3;
|
||||||
private static _uniqueIdCounter: number = 1;
|
private static _uniqueIdCounter: number = 1;
|
||||||
|
|
||||||
|
private _textureCache: RoomTextureCache;
|
||||||
private _disposed: boolean;
|
private _disposed: boolean;
|
||||||
private _randomSeed: number;
|
private _randomSeed: number;
|
||||||
private _origin: Vector3d;
|
private _origin: Vector3d;
|
||||||
@ -62,8 +63,9 @@ export class RoomPlane implements IRoomPlane
|
|||||||
private _height: number = 0;
|
private _height: number = 0;
|
||||||
private _canBeVisible: boolean;
|
private _canBeVisible: boolean;
|
||||||
|
|
||||||
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(textureCache: RoomTextureCache, 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)
|
||||||
{
|
{
|
||||||
|
this._textureCache = textureCache;
|
||||||
this._secondaryNormals = [];
|
this._secondaryNormals = [];
|
||||||
this._bitmapMasks = [];
|
this._bitmapMasks = [];
|
||||||
this._rectangleMasks = [];
|
this._rectangleMasks = [];
|
||||||
@ -390,13 +392,13 @@ export class RoomPlane implements IRoomPlane
|
|||||||
|
|
||||||
if(this._rasterizer)
|
if(this._rasterizer)
|
||||||
{
|
{
|
||||||
bitmapData = this._rasterizer.render(this._uniqueId.toString(), texture, this._id, width, height, geometry.scale, normal, this._hasTexture, this._textureOffsetX, this._textureOffsetY, this._textureMaxX, this._textureMaxY, timeSinceStartMs);
|
bitmapData = this._rasterizer.render(this._uniqueId.toString(), this._textureCache, texture, this._id, width, height, geometry.scale, normal, this._hasTexture, this._textureOffsetX, this._textureOffsetY, this._textureMaxX, this._textureMaxY, timeSinceStartMs);
|
||||||
|
|
||||||
if(bitmapData && texture && (bitmapData?.texture !== texture)) texture.destroy(true);
|
if(bitmapData && texture && (bitmapData?.texture !== texture)) texture.destroy(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const renderTexture = RoomTextureUtils.createAndFillRenderTexture(width, height);
|
const renderTexture = this._textureCache.createAndFillRenderTexture(width, height);
|
||||||
|
|
||||||
bitmapData = new PlaneBitmapData(renderTexture, -1);
|
bitmapData = new PlaneBitmapData(renderTexture, -1);
|
||||||
}
|
}
|
||||||
@ -623,7 +625,7 @@ export class RoomPlane implements IRoomPlane
|
|||||||
|
|
||||||
if((this._width < 1) || (this._height < 1)) return true;
|
if((this._width < 1) || (this._height < 1)) return true;
|
||||||
|
|
||||||
this._bitmapData = RoomTextureUtils.createAndFillRenderTexture(this._width, this._height);
|
this._bitmapData = this._textureCache.createAndFillRenderTexture(this._width, this._height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -636,21 +638,21 @@ export class RoomPlane implements IRoomPlane
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureUtils.clearAndFillRenderTexture(this._bitmapData);
|
this._textureCache.clearAndFillRenderTexture(this._bitmapData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if((this._width < 1) || (this._height < 1)) return false;
|
if((this._width < 1) || (this._height < 1)) return false;
|
||||||
|
|
||||||
this._bitmapData = RoomTextureUtils.createAndFillRenderTexture(this._width, this._height);
|
this._bitmapData = this._textureCache.createAndFillRenderTexture(this._width, this._height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this._bitmapData) return false;
|
if(!this._bitmapData) return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TextureUtils.clearAndFillRenderTexture(this._bitmapData);
|
this._textureCache.clearAndFillRenderTexture(this._bitmapData);
|
||||||
}
|
}
|
||||||
|
|
||||||
Randomizer.setSeed(this._randomSeed);
|
Randomizer.setSeed(this._randomSeed);
|
||||||
@ -758,7 +760,7 @@ export class RoomPlane implements IRoomPlane
|
|||||||
//k.baseTexture.mipmap = MIPMAP_MODES.OFF;
|
//k.baseTexture.mipmap = MIPMAP_MODES.OFF;
|
||||||
//k.baseTexture.scaleMode = SCALE_MODES.LINEAR;
|
//k.baseTexture.scaleMode = SCALE_MODES.LINEAR;
|
||||||
|
|
||||||
TextureUtils.writeToRenderTexture(new Sprite(k), this._bitmapData, true, matrix);
|
this._textureCache.writeToRenderTexture(new Sprite(k), this._bitmapData, true, matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public resetBitmapMasks(): void
|
public resetBitmapMasks(): void
|
||||||
@ -881,7 +883,7 @@ export class RoomPlane implements IRoomPlane
|
|||||||
this._maskBitmapData = null;
|
this._maskBitmapData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._maskBitmapData = RoomTextureUtils.createAndFillRenderTexture(width, height);
|
this._maskBitmapData = this._textureCache.createAndFillRenderTexture(width, height);
|
||||||
this._maskChanged = true;
|
this._maskChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -890,7 +892,7 @@ export class RoomPlane implements IRoomPlane
|
|||||||
this._bitmapMasksOld = [];
|
this._bitmapMasksOld = [];
|
||||||
this._rectangleMasksOld = [];
|
this._rectangleMasksOld = [];
|
||||||
|
|
||||||
if(this._maskBitmapData) TextureUtils.clearAndFillRenderTexture(this._maskBitmapData);
|
if(this._maskBitmapData) this._textureCache.clearAndFillRenderTexture(this._maskBitmapData);
|
||||||
|
|
||||||
this.resetTextureCache(canvas);
|
this.resetTextureCache(canvas);
|
||||||
|
|
||||||
@ -943,7 +945,7 @@ export class RoomPlane implements IRoomPlane
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._maskPixels = TextureUtils.getPixels(this._maskBitmapData);
|
this._maskPixels = this._textureCache.getPixels(this._maskBitmapData);
|
||||||
|
|
||||||
this._maskChanged = false;
|
this._maskChanged = false;
|
||||||
}
|
}
|
||||||
@ -955,7 +957,7 @@ export class RoomPlane implements IRoomPlane
|
|||||||
{
|
{
|
||||||
if(!canvas || !maskPixels) return;
|
if(!canvas || !maskPixels) return;
|
||||||
|
|
||||||
const canvasPixels = TextureUtils.getPixels(canvas);
|
const canvasPixels = this._textureCache.getPixels(canvas);
|
||||||
|
|
||||||
for(let i = 0; i < canvasPixels.length; i += 4)
|
for(let i = 0; i < canvasPixels.length; i += 4)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Rectangle } from '@pixi/math';
|
import { Rectangle } from '@pixi/math';
|
||||||
import { AlphaTolerance, IObjectVisualizationData, IPlaneVisualization, IRoomGeometry, IRoomObjectModel, IRoomObjectSprite, IRoomPlane, RoomObjectSpriteType, RoomObjectVariable, Vector3d } from '../../../../../api';
|
import { AlphaTolerance, IObjectVisualizationData, IPlaneVisualization, IRoomGeometry, IRoomObjectModel, IRoomObjectSprite, IRoomPlane, RoomObjectSpriteType, RoomObjectVariable, Vector3d } from '../../../../../api';
|
||||||
import { RoomTextureUtils } from '../../../../../pixi-proxy';
|
import { RoomTextureCache } from '../../../../../pixi-proxy';
|
||||||
import { RoomObjectSpriteVisualization } from '../../../../../room';
|
import { RoomObjectSpriteVisualization } from '../../../../../room';
|
||||||
import { ToInt32 } from '../../../../utils';
|
import { ToInt32 } from '../../../../utils';
|
||||||
import { RoomMapData } from '../../RoomMapData';
|
import { RoomMapData } from '../../RoomMapData';
|
||||||
@ -57,6 +57,7 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
|
|||||||
private _assetUpdateCounter: number;
|
private _assetUpdateCounter: number;
|
||||||
private _maskData: RoomMapMaskData;
|
private _maskData: RoomMapMaskData;
|
||||||
private _isPlaneSet: boolean;
|
private _isPlaneSet: boolean;
|
||||||
|
private _textureCache: RoomTextureCache;
|
||||||
|
|
||||||
constructor()
|
constructor()
|
||||||
{
|
{
|
||||||
@ -92,6 +93,7 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
|
|||||||
this._assetUpdateCounter = 0;
|
this._assetUpdateCounter = 0;
|
||||||
this._maskData = null;
|
this._maskData = null;
|
||||||
this._isPlaneSet = false;
|
this._isPlaneSet = false;
|
||||||
|
this._textureCache = new RoomTextureCache();
|
||||||
|
|
||||||
this._typeVisibility[RoomPlane.TYPE_UNDEFINED] = false;
|
this._typeVisibility[RoomPlane.TYPE_UNDEFINED] = false;
|
||||||
this._typeVisibility[RoomPlane.TYPE_FLOOR] = true;
|
this._typeVisibility[RoomPlane.TYPE_FLOOR] = true;
|
||||||
@ -143,7 +145,11 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
|
|||||||
this._data = null;
|
this._data = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomTextureUtils.clearCache();
|
if(this._textureCache)
|
||||||
|
{
|
||||||
|
console.log('clear it');
|
||||||
|
this._textureCache.clearCache();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected reset(): void
|
protected reset(): void
|
||||||
@ -409,7 +415,7 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
|
|||||||
const textureOffsetX = (Math.trunc(_local_15) - _local_15);
|
const textureOffsetX = (Math.trunc(_local_15) - _local_15);
|
||||||
const textureOffsetY = (Math.trunc(_local_16) - _local_16);
|
const textureOffsetY = (Math.trunc(_local_16) - _local_16);
|
||||||
|
|
||||||
plane = new RoomPlane(this.object.getLocation(), location, leftSide, rightSide, RoomPlane.TYPE_FLOOR, true, secondaryNormals, randomSeed, -(textureOffsetX), -(textureOffsetY));
|
plane = new RoomPlane(this._textureCache, this.object.getLocation(), location, leftSide, rightSide, RoomPlane.TYPE_FLOOR, true, secondaryNormals, randomSeed, -(textureOffsetX), -(textureOffsetY));
|
||||||
|
|
||||||
if(_local_14.z !== 0)
|
if(_local_14.z !== 0)
|
||||||
{
|
{
|
||||||
@ -425,7 +431,7 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
|
|||||||
|
|
||||||
else if(planeType === RoomPlaneData.PLANE_WALL)
|
else if(planeType === RoomPlaneData.PLANE_WALL)
|
||||||
{
|
{
|
||||||
plane = new RoomPlane(this.object.getLocation(), location, leftSide, rightSide, RoomPlane.TYPE_WALL, true, secondaryNormals, randomSeed);
|
plane = new RoomPlane(this._textureCache, this.object.getLocation(), location, leftSide, rightSide, RoomPlane.TYPE_WALL, true, secondaryNormals, randomSeed);
|
||||||
|
|
||||||
if((leftSide.length < 1) || (rightSide.length < 1))
|
if((leftSide.length < 1) || (rightSide.length < 1))
|
||||||
{
|
{
|
||||||
@ -460,7 +466,7 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
|
|||||||
|
|
||||||
else if(planeType === RoomPlaneData.PLANE_LANDSCAPE)
|
else if(planeType === RoomPlaneData.PLANE_LANDSCAPE)
|
||||||
{
|
{
|
||||||
plane = new RoomPlane(this.object.getLocation(), location, leftSide, rightSide, RoomPlane.TYPE_LANDSCAPE, true, secondaryNormals, randomSeed, _local_5, 0, maxX, maxY);
|
plane = new RoomPlane(this._textureCache, this.object.getLocation(), location, leftSide, rightSide, RoomPlane.TYPE_LANDSCAPE, true, secondaryNormals, randomSeed, _local_5, 0, maxX, maxY);
|
||||||
|
|
||||||
if(_local_14.y > 0)
|
if(_local_14.y > 0)
|
||||||
{
|
{
|
||||||
@ -485,7 +491,7 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
|
|||||||
|
|
||||||
else if(planeType == RoomPlaneData.PLANE_BILLBOARD)
|
else if(planeType == RoomPlaneData.PLANE_BILLBOARD)
|
||||||
{
|
{
|
||||||
plane = new RoomPlane(this.object.getLocation(), location, leftSide, rightSide, RoomPlane.TYPE_WALL, true, secondaryNormals, randomSeed);
|
plane = new RoomPlane(this._textureCache, this.object.getLocation(), location, leftSide, rightSide, RoomPlane.TYPE_WALL, true, secondaryNormals, randomSeed);
|
||||||
if(((leftSide.length < 1) || (rightSide.length < 1)))
|
if(((leftSide.length < 1) || (rightSide.length < 1)))
|
||||||
{
|
{
|
||||||
plane.hasTexture = false;
|
plane.hasTexture = false;
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import { RenderTexture } from '@pixi/core';
|
import { RenderTexture } from '@pixi/core';
|
||||||
import { IVector3D } from '../../../../../../api';
|
import { IVector3D } from '../../../../../../api';
|
||||||
|
import { RoomTextureCache } from '../../../../../../pixi-proxy';
|
||||||
import { PlaneBitmapData } from '../utils';
|
import { PlaneBitmapData } from '../utils';
|
||||||
import { PlaneVisualizationLayer } from './basic';
|
import { PlaneVisualizationLayer } from './basic';
|
||||||
|
|
||||||
export interface IPlaneRasterizer
|
export interface IPlaneRasterizer
|
||||||
{
|
{
|
||||||
initializeDimensions(_arg_1: number, _arg_2: number): boolean;
|
initializeDimensions(_arg_1: number, _arg_2: number): boolean;
|
||||||
render(planeId: string, canvas: RenderTexture, id: string, width: number, height: number, scale: number, normal: IVector3D, useTexture: boolean, offsetX?: number, offsetY?: number, maxX?: number, maxY?: number, timeSinceStartMs?: number): PlaneBitmapData;
|
render(planeId: string, textureCache: RoomTextureCache, canvas: RenderTexture, id: string, width: number, height: number, scale: number, normal: IVector3D, useTexture: boolean, offsetX?: number, offsetY?: number, maxX?: number, maxY?: number, timeSinceStartMs?: number): PlaneBitmapData;
|
||||||
getTextureIdentifier(_arg_1: number, _arg_2: IVector3D): string;
|
getTextureIdentifier(_arg_1: number, _arg_2: IVector3D): string;
|
||||||
getLayers(_arg_1: string): PlaneVisualizationLayer[];
|
getLayers(_arg_1: string): PlaneVisualizationLayer[];
|
||||||
reinitialize(): void;
|
reinitialize(): void;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { RenderTexture } from '@pixi/core';
|
import { RenderTexture } from '@pixi/core';
|
||||||
import { IVector3D, Vector3d } from '../../../../../../../api';
|
import { IVector3D, Vector3d } from '../../../../../../../api';
|
||||||
|
import { RoomTextureCache } from '../../../../../../../pixi-proxy';
|
||||||
import { Plane } from '../basic';
|
import { Plane } from '../basic';
|
||||||
|
|
||||||
export class LandscapePlane extends Plane
|
export class LandscapePlane extends Plane
|
||||||
@ -33,7 +34,7 @@ export class LandscapePlane extends Plane
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(planeId: string, canvas: RenderTexture, width: number, height: number, scale: number, normal: IVector3D, useTexture: boolean, offsetX: number, offsetY: number, maxX: number, maxY: number, timeSinceStartMs: number): RenderTexture
|
public render(planeId: string, textureCache: RoomTextureCache, canvas: RenderTexture, width: number, height: number, scale: number, normal: IVector3D, useTexture: boolean, offsetX: number, offsetY: number, maxX: number, maxY: number, timeSinceStartMs: number): RenderTexture
|
||||||
{
|
{
|
||||||
const visualization = this.getPlaneVisualization(scale);
|
const visualization = this.getPlaneVisualization(scale);
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ export class LandscapePlane extends Plane
|
|||||||
const renderMaxX = Math.trunc(maxX * Math.abs((_local_13.x - _local_15.x)));
|
const renderMaxX = Math.trunc(maxX * Math.abs((_local_13.x - _local_15.x)));
|
||||||
const renderMaxY = Math.trunc(maxY * Math.abs((_local_13.y - _local_14.y)));
|
const renderMaxY = Math.trunc(maxY * Math.abs((_local_13.y - _local_14.y)));
|
||||||
|
|
||||||
return visualization.render(planeId, canvas, width, height, normal, useTexture, renderOffsetX, renderOffsetY, renderMaxX, renderMaxY, maxX, maxY, timeSinceStartMs);
|
return visualization.render(planeId, textureCache, canvas, width, height, normal, useTexture, renderOffsetX, renderOffsetY, renderMaxX, renderMaxY, maxX, maxY, timeSinceStartMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { RenderTexture } from '@pixi/core';
|
import { RenderTexture } from '@pixi/core';
|
||||||
import { IAssetPlane, IAssetPlaneVisualizationAnimatedLayer, IAssetPlaneVisualizationLayer, IVector3D, Vector3d } from '../../../../../../../api';
|
import { IAssetPlane, IAssetPlaneVisualizationAnimatedLayer, IAssetPlaneVisualizationLayer, IVector3D, Vector3d } from '../../../../../../../api';
|
||||||
import { RoomTextureUtils, TextureUtils } from '../../../../../../../pixi-proxy';
|
import { RoomTextureCache } from '../../../../../../../pixi-proxy';
|
||||||
import { PlaneBitmapData, Randomizer } from '../../utils';
|
import { PlaneBitmapData, Randomizer } from '../../utils';
|
||||||
import { PlaneMaterial, PlaneRasterizer, PlaneVisualizationLayer } from '../basic';
|
import { PlaneMaterial, PlaneRasterizer, PlaneVisualizationLayer } from '../basic';
|
||||||
import { LandscapePlane } from './LandscapePlane';
|
import { LandscapePlane } from './LandscapePlane';
|
||||||
@ -184,7 +184,7 @@ export class LandscapeRasterizer extends PlaneRasterizer
|
|||||||
return _local_3;
|
return _local_3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(planeId: string, canvas: RenderTexture, id: string, width: number, height: number, scale: number, normal: IVector3D, useTexture: boolean, offsetX: number = 0, offsetY: number = 0, maxX: number = 0, maxY: number = 0, timeSinceStartMs: number = 0): PlaneBitmapData
|
public render(planeId: string, textureCache: RoomTextureCache, canvas: RenderTexture, id: string, width: number, height: number, scale: number, normal: IVector3D, useTexture: boolean, offsetX: number = 0, offsetY: number = 0, maxX: number = 0, maxY: number = 0, timeSinceStartMs: number = 0): PlaneBitmapData
|
||||||
{
|
{
|
||||||
let plane = this.getPlane(id) as LandscapePlane;
|
let plane = this.getPlane(id) as LandscapePlane;
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ export class LandscapeRasterizer extends PlaneRasterizer
|
|||||||
|
|
||||||
if(!plane) return null;
|
if(!plane) return null;
|
||||||
|
|
||||||
if(canvas) TextureUtils.clearRenderTexture(canvas);
|
if(canvas) textureCache.clearRenderTexture(canvas);
|
||||||
|
|
||||||
if(!LandscapeRasterizer.LANDSCAPES_ENABLED)
|
if(!LandscapeRasterizer.LANDSCAPES_ENABLED)
|
||||||
{
|
{
|
||||||
@ -219,15 +219,15 @@ export class LandscapeRasterizer extends PlaneRasterizer
|
|||||||
this._cachedBitmap = null;
|
this._cachedBitmap = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._cachedBitmap = RoomTextureUtils.createAndFillRenderTexture(width, height, LandscapeRasterizer.LANDSCAPE_DEFAULT_COLOR);
|
this._cachedBitmap = textureCache.createAndFillRenderTexture(width, height, LandscapeRasterizer.LANDSCAPE_DEFAULT_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PlaneBitmapData(this._cachedBitmap, -1);
|
return new PlaneBitmapData(this._cachedBitmap, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(canvas) TextureUtils.clearRenderTexture(canvas);
|
if(canvas) textureCache.clearRenderTexture(canvas);
|
||||||
|
|
||||||
let graphic = plane.render(planeId, canvas, width, height, scale, normal, useTexture, offsetX, offsetY, maxX, maxY, timeSinceStartMs);
|
let graphic = plane.render(planeId,textureCache, canvas, width, height, scale, normal, useTexture, offsetX, offsetY, maxX, maxY, timeSinceStartMs);
|
||||||
|
|
||||||
if(graphic && (graphic !== canvas))
|
if(graphic && (graphic !== canvas))
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { RenderTexture } from '@pixi/core';
|
import { RenderTexture } from '@pixi/core';
|
||||||
import { Sprite } from '@pixi/sprite';
|
import { Sprite } from '@pixi/sprite';
|
||||||
import { IDisposable, IGraphicAssetCollection, IVector3D } from '../../../../../../../api';
|
import { IDisposable, IGraphicAssetCollection, IVector3D } from '../../../../../../../api';
|
||||||
import { RoomTextureUtils, TextureUtils } from '../../../../../../../pixi-proxy';
|
import { RoomTextureCache } from '../../../../../../../pixi-proxy';
|
||||||
import { AnimationItem } from './AnimationItem';
|
import { AnimationItem } from './AnimationItem';
|
||||||
|
|
||||||
export class PlaneVisualizationAnimationLayer implements IDisposable
|
export class PlaneVisualizationAnimationLayer implements IDisposable
|
||||||
@ -70,7 +70,7 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(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: RoomTextureCache, 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(!canvas || (canvas.width !== width) || (canvas.height !== height))
|
||||||
{
|
{
|
||||||
@ -78,11 +78,11 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
|
|||||||
{
|
{
|
||||||
if(this._bitmapData) this._bitmapData.destroy(true);
|
if(this._bitmapData) this._bitmapData.destroy(true);
|
||||||
|
|
||||||
this._bitmapData = RoomTextureUtils.createRenderTexture(width, height);
|
this._bitmapData = textureCache.createRenderTexture(width, height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TextureUtils.clearRenderTexture(this._bitmapData);
|
textureCache.clearRenderTexture(this._bitmapData);
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas = this._bitmapData;
|
canvas = this._bitmapData;
|
||||||
@ -111,7 +111,7 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
|
|||||||
|
|
||||||
sprite.position.set(point.x, point.y);
|
sprite.position.set(point.x, point.y);
|
||||||
|
|
||||||
TextureUtils.writeToRenderTexture(sprite, canvas, false);
|
textureCache.writeToRenderTexture(sprite, canvas, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(((point.x - maxX) > -(item.bitmapData.width)) && ((point.x - maxX) < canvas.width) && (point.y > -(item.bitmapData.height)) && (point.y < canvas.height))
|
if(((point.x - maxX) > -(item.bitmapData.width)) && ((point.x - maxX) < canvas.width) && (point.y > -(item.bitmapData.height)) && (point.y < canvas.height))
|
||||||
@ -120,7 +120,7 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
|
|||||||
|
|
||||||
sprite.position.set((point.x - maxX), point.y);
|
sprite.position.set((point.x - maxX), point.y);
|
||||||
|
|
||||||
TextureUtils.writeToRenderTexture(sprite, canvas, false);
|
textureCache.writeToRenderTexture(sprite, canvas, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((point.x > -(item.bitmapData.width)) && (point.x < canvas.width) && ((point.y - maxY) > -(item.bitmapData.height)) && ((point.y - maxY) < canvas.height))
|
if((point.x > -(item.bitmapData.width)) && (point.x < canvas.width) && ((point.y - maxY) > -(item.bitmapData.height)) && ((point.y - maxY) < canvas.height))
|
||||||
@ -129,7 +129,7 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
|
|||||||
|
|
||||||
sprite.position.set(point.x, (point.y - maxY));
|
sprite.position.set(point.x, (point.y - maxY));
|
||||||
|
|
||||||
TextureUtils.writeToRenderTexture(sprite, canvas, false);
|
textureCache.writeToRenderTexture(sprite, canvas, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(((point.x - maxX) > -(item.bitmapData.width)) && ((point.x - maxX) < canvas.width) && ((point.y - maxY) > -(item.bitmapData.height)) && ((point.y - maxY) < canvas.height))
|
if(((point.x - maxX) > -(item.bitmapData.width)) && ((point.x - maxX) < canvas.width) && ((point.y - maxY) > -(item.bitmapData.height)) && ((point.y - maxY) < canvas.height))
|
||||||
@ -138,7 +138,7 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
|
|||||||
|
|
||||||
sprite.position.set((point.x - maxX), (point.y - maxY));
|
sprite.position.set((point.x - maxX), (point.y - maxY));
|
||||||
|
|
||||||
TextureUtils.writeToRenderTexture(sprite, canvas, false);
|
textureCache.writeToRenderTexture(sprite, canvas, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { RenderTexture } from '@pixi/core';
|
import { RenderTexture } from '@pixi/core';
|
||||||
import { IVector3D, Vector3d } from '../../../../../../../api';
|
import { IVector3D, Vector3d } from '../../../../../../../api';
|
||||||
|
import { RoomTextureCache } from '../../../../../../../pixi-proxy';
|
||||||
import { Plane } from './Plane';
|
import { Plane } from './Plane';
|
||||||
|
|
||||||
export class FloorPlane extends Plane
|
export class FloorPlane extends Plane
|
||||||
@ -8,7 +9,7 @@ export class FloorPlane extends Plane
|
|||||||
public static HORIZONTAL_ANGLE_DEFAULT: number = 45;
|
public static HORIZONTAL_ANGLE_DEFAULT: number = 45;
|
||||||
public static VERTICAL_ANGLE_DEFAULT: number = 30;
|
public static VERTICAL_ANGLE_DEFAULT: number = 30;
|
||||||
|
|
||||||
public render(planeId: string, canvas: RenderTexture, width: number, height: number, scale: number, normal: IVector3D, useTexture: boolean, offsetX: number, offsetY: number): RenderTexture
|
public render(planeId: string, textureCache: RoomTextureCache, canvas: RenderTexture, width: number, height: number, scale: number, normal: IVector3D, useTexture: boolean, offsetX: number, offsetY: number): RenderTexture
|
||||||
{
|
{
|
||||||
const visualization = this.getPlaneVisualization(scale);
|
const visualization = this.getPlaneVisualization(scale);
|
||||||
|
|
||||||
@ -32,6 +33,6 @@ export class FloorPlane extends Plane
|
|||||||
y = (offsetY * Math.trunc(Math.abs(_local_15)));
|
y = (offsetY * Math.trunc(Math.abs(_local_15)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return visualization.render(planeId, canvas, width, height, normal, useTexture, x, y);
|
return visualization.render(planeId, textureCache, canvas, width, height, normal, useTexture, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { RenderTexture } from '@pixi/core';
|
import { RenderTexture } from '@pixi/core';
|
||||||
import { IAssetPlane, IVector3D } from '../../../../../../../api';
|
import { IAssetPlane, IVector3D } from '../../../../../../../api';
|
||||||
import { TextureUtils } from '../../../../../../../pixi-proxy';
|
import { RoomTextureCache } from '../../../../../../../pixi-proxy';
|
||||||
import { PlaneBitmapData } from '../../utils';
|
import { PlaneBitmapData } from '../../utils';
|
||||||
import { FloorPlane } from './FloorPlane';
|
import { FloorPlane } from './FloorPlane';
|
||||||
import { PlaneRasterizer } from './PlaneRasterizer';
|
import { PlaneRasterizer } from './PlaneRasterizer';
|
||||||
@ -36,7 +36,7 @@ export class FloorRasterizer extends PlaneRasterizer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(planeId: string, canvas: RenderTexture, id: string, width: number, height: number, scale: number, normal: IVector3D, useTexture: boolean, offsetX: number = 0, offsetY: number = 0, maxX: number = 0, maxY: number = 0, timeSinceStartMs: number = 0): PlaneBitmapData
|
public render(planeId: string, textureCache: RoomTextureCache, canvas: RenderTexture, id: string, width: number, height: number, scale: number, normal: IVector3D, useTexture: boolean, offsetX: number = 0, offsetY: number = 0, maxX: number = 0, maxY: number = 0, timeSinceStartMs: number = 0): PlaneBitmapData
|
||||||
{
|
{
|
||||||
let plane = this.getPlane(id) as FloorPlane;
|
let plane = this.getPlane(id) as FloorPlane;
|
||||||
|
|
||||||
@ -44,9 +44,9 @@ export class FloorRasterizer extends PlaneRasterizer
|
|||||||
|
|
||||||
if(!plane) return null;
|
if(!plane) return null;
|
||||||
|
|
||||||
if(canvas) TextureUtils.clearAndFillRenderTexture(canvas);
|
if(canvas) textureCache.clearAndFillRenderTexture(canvas);
|
||||||
|
|
||||||
let graphic = plane.render(planeId, canvas, width, height, scale, normal, useTexture, offsetX, offsetY);
|
let graphic = plane.render(planeId, textureCache, canvas, width, height, scale, normal, useTexture, offsetX, offsetY);
|
||||||
|
|
||||||
if(graphic && (graphic !== canvas))
|
if(graphic && (graphic !== canvas))
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { RenderTexture } from '@pixi/core';
|
import { RenderTexture } from '@pixi/core';
|
||||||
import { IVector3D } from '../../../../../../../api';
|
import { IVector3D } from '../../../../../../../api';
|
||||||
|
import { RoomTextureCache } from '../../../../../../../pixi-proxy';
|
||||||
import { PlaneMaterialCellMatrix } from './PlaneMaterialCellMatrix';
|
import { PlaneMaterialCellMatrix } from './PlaneMaterialCellMatrix';
|
||||||
|
|
||||||
export class PlaneMaterial
|
export class PlaneMaterial
|
||||||
@ -76,7 +77,7 @@ export class PlaneMaterial
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(canvas: RenderTexture, width: number, height: number, normal: IVector3D, useTexture: boolean, offsetX: number, offsetY: number, topAlign: boolean): RenderTexture
|
public render(textureCache: RoomTextureCache, canvas: RenderTexture, width: number, height: number, normal: IVector3D, useTexture: boolean, offsetX: number, offsetY: number, topAlign: boolean): RenderTexture
|
||||||
{
|
{
|
||||||
if(width < 1) width = 1;
|
if(width < 1) width = 1;
|
||||||
|
|
||||||
@ -88,6 +89,6 @@ export class PlaneMaterial
|
|||||||
|
|
||||||
this._isCached = true;
|
this._isCached = true;
|
||||||
|
|
||||||
return cellMatrix.render(canvas, width, height, normal, useTexture, offsetX, offsetY, topAlign);
|
return cellMatrix.render(textureCache, canvas, width, height, normal, useTexture, offsetX, offsetY, topAlign);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { RenderTexture, Texture } from '@pixi/core';
|
import { RenderTexture, Texture } from '@pixi/core';
|
||||||
import { Sprite } from '@pixi/sprite';
|
import { Sprite } from '@pixi/sprite';
|
||||||
import { IVector3D, Vector3d } from '../../../../../../../api';
|
import { IVector3D, Vector3d } from '../../../../../../../api';
|
||||||
import { RoomTextureUtils, TextureUtils } from '../../../../../../../pixi-proxy';
|
import { RoomTextureCache, TextureUtils } from '../../../../../../../pixi-proxy';
|
||||||
import { PlaneMaterialCell } from './PlaneMaterialCell';
|
import { PlaneMaterialCell } from './PlaneMaterialCell';
|
||||||
|
|
||||||
export class PlaneMaterialCellColumn
|
export class PlaneMaterialCellColumn
|
||||||
@ -125,7 +125,7 @@ export class PlaneMaterialCellColumn
|
|||||||
this._isCached = false;
|
this._isCached = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(height: number, normal: IVector3D, offsetX: number, offsetY: number): RenderTexture
|
public render(textureCache: RoomTextureCache, height: number, normal: IVector3D, offsetX: number, offsetY: number): RenderTexture
|
||||||
{
|
{
|
||||||
if(this._repeatMode === PlaneMaterialCellColumn.REPEAT_MODE_NONE) height = this.getCellsHeight(this._cells, normal);
|
if(this._repeatMode === PlaneMaterialCellColumn.REPEAT_MODE_NONE) height = this.getCellsHeight(this._cells, normal);
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ export class PlaneMaterialCellColumn
|
|||||||
{
|
{
|
||||||
if(this._cachedBitmapData.height === height)
|
if(this._cachedBitmapData.height === height)
|
||||||
{
|
{
|
||||||
TextureUtils.clearRenderTexture(this._cachedBitmapData);
|
textureCache.clearRenderTexture(this._cachedBitmapData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -165,7 +165,7 @@ export class PlaneMaterialCellColumn
|
|||||||
sprite.width = this._cachedBitmapData.width;
|
sprite.width = this._cachedBitmapData.width;
|
||||||
sprite.height = height;
|
sprite.height = height;
|
||||||
|
|
||||||
TextureUtils.writeToRenderTexture(sprite, this._cachedBitmapData);
|
textureCache.writeToRenderTexture(sprite, this._cachedBitmapData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -180,7 +180,7 @@ export class PlaneMaterialCellColumn
|
|||||||
|
|
||||||
if(!this._cachedBitmapData)
|
if(!this._cachedBitmapData)
|
||||||
{
|
{
|
||||||
this._cachedBitmapData = RoomTextureUtils.createRenderTexture(this._width, height);
|
this._cachedBitmapData = textureCache.createRenderTexture(this._width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._cachedBitmapNormal.assign(normal);
|
this._cachedBitmapNormal.assign(normal);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import { Point, Rectangle } from '@pixi/math';
|
import { Point, Rectangle } from '@pixi/math';
|
||||||
import { Sprite } from '@pixi/sprite';
|
import { Sprite } from '@pixi/sprite';
|
||||||
import { IVector3D, NitroLogger, Vector3d } from '../../../../../../../api';
|
import { IVector3D, NitroLogger, Vector3d } from '../../../../../../../api';
|
||||||
import { RoomTextureUtils, TextureUtils } from '../../../../../../../pixi-proxy';
|
import { RoomTextureCache, TextureUtils } from '../../../../../../../pixi-proxy';
|
||||||
import { Randomizer } from '../../utils';
|
import { Randomizer } from '../../utils';
|
||||||
import { PlaneMaterialCell } from './PlaneMaterialCell';
|
import { PlaneMaterialCell } from './PlaneMaterialCell';
|
||||||
import { PlaneMaterialCellColumn } from './PlaneMaterialCellColumn';
|
import { PlaneMaterialCellColumn } from './PlaneMaterialCellColumn';
|
||||||
@ -165,7 +165,7 @@ export class PlaneMaterialCellMatrix
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(canvas: RenderTexture, width: number, height: number, normal: IVector3D, useTexture: boolean, offsetX: number, offsetY: number, topAlign: boolean): RenderTexture
|
public render(textureCache: RoomTextureCache, canvas: RenderTexture, width: number, height: number, normal: IVector3D, useTexture: boolean, offsetX: number, offsetY: number, topAlign: boolean): RenderTexture
|
||||||
{
|
{
|
||||||
if(width < 1) width = 1;
|
if(width < 1) width = 1;
|
||||||
|
|
||||||
@ -212,18 +212,18 @@ export class PlaneMaterialCellMatrix
|
|||||||
|
|
||||||
if(!this._cachedBitmapData)
|
if(!this._cachedBitmapData)
|
||||||
{
|
{
|
||||||
this._cachedBitmapData = RoomTextureUtils.createAndFillRenderTexture(width, height);
|
this._cachedBitmapData = textureCache.createAndFillRenderTexture(width, height);
|
||||||
|
|
||||||
this._texturePool.set(`${width}:${height}`, this._cachedBitmapData);
|
this._texturePool.set(`${width}:${height}`, this._cachedBitmapData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TextureUtils.clearAndFillRenderTexture(this._cachedBitmapData);
|
textureCache.clearAndFillRenderTexture(this._cachedBitmapData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TextureUtils.clearAndFillRenderTexture(this._cachedBitmapData);
|
textureCache.clearAndFillRenderTexture(this._cachedBitmapData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(canvas)
|
if(canvas)
|
||||||
@ -244,13 +244,13 @@ export class PlaneMaterialCellMatrix
|
|||||||
|
|
||||||
if(!this._cachedBitmapData)
|
if(!this._cachedBitmapData)
|
||||||
{
|
{
|
||||||
this._cachedBitmapData = RoomTextureUtils.createRenderTexture(width, height);
|
this._cachedBitmapData = textureCache.createRenderTexture(width, height);
|
||||||
|
|
||||||
this._texturePool.set(`${width}:${height}`, this._cachedBitmapData);
|
this._texturePool.set(`${width}:${height}`, this._cachedBitmapData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TextureUtils.clearRenderTexture(this._cachedBitmapData);
|
textureCache.clearRenderTexture(this._cachedBitmapData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ export class PlaneMaterialCellMatrix
|
|||||||
|
|
||||||
if(column)
|
if(column)
|
||||||
{
|
{
|
||||||
const columnBitmapData = column.render(height, normal, offsetX, offsetY);
|
const columnBitmapData = column.render(textureCache, height, normal, offsetX, offsetY);
|
||||||
|
|
||||||
if(columnBitmapData) columns.push(columnBitmapData);
|
if(columnBitmapData) columns.push(columnBitmapData);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { RenderTexture, Resource, Texture } from '@pixi/core';
|
import { RenderTexture, Resource, Texture } from '@pixi/core';
|
||||||
import { Point } from '@pixi/math';
|
import { Point } from '@pixi/math';
|
||||||
import { IAssetPlaneMaterial, IAssetPlaneMaterialCellColumn, IAssetPlaneTexture, IAssetPlaneVisualization, IAssetPlaneVisualizationData, IAssetPlaneVisualizationLayer, IGraphicAsset, IGraphicAssetCollection, IRoomGeometry, IVector3D, Vector3d } from '../../../../../../../api';
|
import { IAssetPlaneMaterial, IAssetPlaneMaterialCellColumn, IAssetPlaneTexture, IAssetPlaneVisualization, IAssetPlaneVisualizationData, IAssetPlaneVisualizationLayer, IGraphicAsset, IGraphicAssetCollection, IRoomGeometry, IVector3D, Vector3d } from '../../../../../../../api';
|
||||||
|
import { RoomTextureCache } from '../../../../../../../pixi-proxy';
|
||||||
import { Rasterizer, RoomGeometry } from '../../../../../../../room';
|
import { Rasterizer, RoomGeometry } from '../../../../../../../room';
|
||||||
import { PlaneBitmapData } from '../../utils';
|
import { PlaneBitmapData } from '../../utils';
|
||||||
import { IPlaneRasterizer } from '../IPlaneRasterizer';
|
import { IPlaneRasterizer } from '../IPlaneRasterizer';
|
||||||
@ -584,7 +585,7 @@ export class PlaneRasterizer implements IPlaneRasterizer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(planeId: string, canvas: RenderTexture, id: string, width: number, height: number, size: number, normal: IVector3D, useTexture: boolean, offsetX: number = 0, offsetY: number = 0, maxX: number = 0, maxY: number = 0, timeSinceStartMs: number = 0): PlaneBitmapData
|
public render(planeId: string, textureCache: RoomTextureCache, canvas: RenderTexture, id: string, width: number, height: number, size: number, normal: IVector3D, useTexture: boolean, offsetX: number = 0, offsetY: number = 0, maxX: number = 0, maxY: number = 0, timeSinceStartMs: number = 0): PlaneBitmapData
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { RenderTexture } from '@pixi/core';
|
import { RenderTexture } from '@pixi/core';
|
||||||
import { Sprite } from '@pixi/sprite';
|
import { Sprite } from '@pixi/sprite';
|
||||||
import { IDisposable, IGraphicAssetCollection, IRoomGeometry, IVector3D, Vector3d } from '../../../../../../../api';
|
import { IDisposable, IGraphicAssetCollection, IRoomGeometry, IVector3D, Vector3d } from '../../../../../../../api';
|
||||||
import { RoomTextureUtils, TextureUtils } from '../../../../../../../pixi-proxy';
|
import { RoomTextureCache } from '../../../../../../../pixi-proxy';
|
||||||
import { PlaneVisualizationAnimationLayer } from '../animated';
|
import { PlaneVisualizationAnimationLayer } from '../animated';
|
||||||
import { PlaneMaterial } from './PlaneMaterial';
|
import { PlaneMaterial } from './PlaneMaterial';
|
||||||
import { PlaneVisualizationLayer } from './PlaneVisualizationLayer';
|
import { PlaneVisualizationLayer } from './PlaneVisualizationLayer';
|
||||||
@ -148,7 +148,7 @@ export class PlaneVisualization
|
|||||||
return this._layers as PlaneVisualizationLayer[];
|
return this._layers as PlaneVisualizationLayer[];
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(planeId: string, canvas: RenderTexture, width: number, height: number, normal: IVector3D, useTexture: boolean, offsetX: number = 0, offsetY: number = 0, maxX: number = 0, maxY: number = 0, dimensionX: number = 0, dimensionY: number = 0, timeSinceStartMs: number = 0): RenderTexture
|
public render(planeId: string, textureCache: RoomTextureCache, canvas: RenderTexture, width: number, height: number, normal: IVector3D, useTexture: boolean, offsetX: number = 0, offsetY: number = 0, maxX: number = 0, maxY: number = 0, dimensionX: number = 0, dimensionY: number = 0, timeSinceStartMs: number = 0): RenderTexture
|
||||||
{
|
{
|
||||||
if(width < 1) width = 1;
|
if(width < 1) width = 1;
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ export class PlaneVisualization
|
|||||||
{
|
{
|
||||||
if(canvas)
|
if(canvas)
|
||||||
{
|
{
|
||||||
TextureUtils.writeToRenderTexture(new Sprite(this._cachedBitmapData), canvas, true);
|
textureCache.writeToRenderTexture(new Sprite(this._cachedBitmapData), canvas, true);
|
||||||
|
|
||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ export class PlaneVisualization
|
|||||||
|
|
||||||
if(!swapCache)
|
if(!swapCache)
|
||||||
{
|
{
|
||||||
swapCache = RoomTextureUtils.createAndFillRenderTexture(width, height);
|
swapCache = textureCache.createAndFillRenderTexture(width, height);
|
||||||
|
|
||||||
this._texturePool.set(planeId + '-swap', swapCache);
|
this._texturePool.set(planeId + '-swap', swapCache);
|
||||||
}
|
}
|
||||||
@ -201,18 +201,18 @@ export class PlaneVisualization
|
|||||||
|
|
||||||
if(!cache)
|
if(!cache)
|
||||||
{
|
{
|
||||||
cache = RoomTextureUtils.createAndFillRenderTexture(width, height);
|
cache = textureCache.createAndFillRenderTexture(width, height);
|
||||||
|
|
||||||
this._texturePool.set(planeId, cache);
|
this._texturePool.set(planeId, cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._cachedBitmapData = swapCache;
|
this._cachedBitmapData = swapCache;
|
||||||
|
|
||||||
TextureUtils.clearAndFillRenderTexture(this._cachedBitmapData);
|
textureCache.clearAndFillRenderTexture(this._cachedBitmapData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TextureUtils.clearAndFillRenderTexture(this._cachedBitmapData);
|
textureCache.clearAndFillRenderTexture(this._cachedBitmapData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!canvas) canvas = this._cachedBitmapData;
|
if(!canvas) canvas = this._cachedBitmapData;
|
||||||
@ -227,19 +227,19 @@ export class PlaneVisualization
|
|||||||
|
|
||||||
if(layer instanceof PlaneVisualizationLayer)
|
if(layer instanceof PlaneVisualizationLayer)
|
||||||
{
|
{
|
||||||
layer.render(canvas, width, height, normal, useTexture, offsetX, offsetY);
|
layer.render(textureCache, canvas, width, height, normal, useTexture, offsetX, offsetY);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(layer instanceof PlaneVisualizationAnimationLayer)
|
else if(layer instanceof PlaneVisualizationAnimationLayer)
|
||||||
{
|
{
|
||||||
layer.render(canvas, width, height, normal, offsetX, offsetY, maxX, maxY, dimensionX, dimensionY, timeSinceStartMs);
|
layer.render(textureCache, canvas, width, height, normal, offsetX, offsetY, maxX, maxY, dimensionX, dimensionY, timeSinceStartMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(canvas && (canvas !== this._cachedBitmapData))
|
if(canvas && (canvas !== this._cachedBitmapData))
|
||||||
{
|
{
|
||||||
TextureUtils.writeToRenderTexture(new Sprite(canvas), this._cachedBitmapData, false);
|
textureCache.writeToRenderTexture(new Sprite(canvas), this._cachedBitmapData, false);
|
||||||
|
|
||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { RenderTexture } from '@pixi/core';
|
import { RenderTexture } from '@pixi/core';
|
||||||
import { Sprite } from '@pixi/sprite';
|
import { Sprite } from '@pixi/sprite';
|
||||||
import { IVector3D } from '../../../../../../../api';
|
import { IVector3D } from '../../../../../../../api';
|
||||||
import { RoomTextureUtils, TextureUtils } from '../../../../../../../pixi-proxy';
|
import { RoomTextureCache } from '../../../../../../../pixi-proxy';
|
||||||
import { PlaneMaterial } from './PlaneMaterial';
|
import { PlaneMaterial } from './PlaneMaterial';
|
||||||
|
|
||||||
export class PlaneVisualizationLayer
|
export class PlaneVisualizationLayer
|
||||||
@ -61,7 +61,7 @@ export class PlaneVisualizationLayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(canvas: RenderTexture, width: number, height: number, normal: IVector3D, useTexture: boolean, offsetX: number, offsetY: number): RenderTexture
|
public render(textureCache: RoomTextureCache, canvas: RenderTexture, width: number, height: number, normal: IVector3D, useTexture: boolean, offsetX: number, offsetY: number): RenderTexture
|
||||||
{
|
{
|
||||||
if(!canvas || (canvas.width !== width) || (canvas.height !== height)) canvas = null;
|
if(!canvas || (canvas.width !== width) || (canvas.height !== height)) canvas = null;
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ export class PlaneVisualizationLayer
|
|||||||
|
|
||||||
if(this._material)
|
if(this._material)
|
||||||
{
|
{
|
||||||
bitmapData = this._material.render(hasColor ? null : canvas, width, height, normal, useTexture, offsetX, (offsetY + this.offset), (this.align === PlaneVisualizationLayer.ALIGN_TOP));
|
bitmapData = this._material.render(textureCache, hasColor ? null : canvas, width, height, normal, useTexture, offsetX, (offsetY + this.offset), (this.align === PlaneVisualizationLayer.ALIGN_TOP));
|
||||||
|
|
||||||
if(bitmapData && (bitmapData !== canvas))
|
if(bitmapData && (bitmapData !== canvas))
|
||||||
{
|
{
|
||||||
@ -94,7 +94,7 @@ export class PlaneVisualizationLayer
|
|||||||
|
|
||||||
sprite.tint = this._color;
|
sprite.tint = this._color;
|
||||||
|
|
||||||
TextureUtils.writeToRenderTexture(sprite, canvas, false);
|
textureCache.writeToRenderTexture(sprite, canvas, false);
|
||||||
|
|
||||||
bitmapData = canvas;
|
bitmapData = canvas;
|
||||||
}
|
}
|
||||||
@ -107,13 +107,13 @@ export class PlaneVisualizationLayer
|
|||||||
|
|
||||||
if(this._bitmapData) this._bitmapData.destroy();
|
if(this._bitmapData) this._bitmapData.destroy();
|
||||||
|
|
||||||
this._bitmapData = RoomTextureUtils.createAndFillRenderTexture(width, height, this._color);
|
this._bitmapData = textureCache.createAndFillRenderTexture(width, height, this._color);
|
||||||
|
|
||||||
bitmapData = this._bitmapData;
|
bitmapData = this._bitmapData;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TextureUtils.clearAndFillRenderTexture(canvas, this._color);
|
textureCache.clearAndFillRenderTexture(canvas, this._color);
|
||||||
|
|
||||||
bitmapData = canvas;
|
bitmapData = canvas;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { RenderTexture } from '@pixi/core';
|
import { RenderTexture } from '@pixi/core';
|
||||||
import { IVector3D, Vector3d } from '../../../../../../../api';
|
import { IVector3D, Vector3d } from '../../../../../../../api';
|
||||||
|
import { RoomTextureCache } from '../../../../../../../pixi-proxy';
|
||||||
import { Plane } from './Plane';
|
import { Plane } from './Plane';
|
||||||
|
|
||||||
export class WallPlane extends Plane
|
export class WallPlane extends Plane
|
||||||
@ -8,7 +9,7 @@ export class WallPlane extends Plane
|
|||||||
public static HORIZONTAL_ANGLE_DEFAULT: number = 45;
|
public static HORIZONTAL_ANGLE_DEFAULT: number = 45;
|
||||||
public static VERTICAL_ANGLE_DEFAULT: number = 30;
|
public static VERTICAL_ANGLE_DEFAULT: number = 30;
|
||||||
|
|
||||||
public render(planeId: string, canvas: RenderTexture, width: number, height: number, size: number, normal: IVector3D, useTexture: boolean): RenderTexture
|
public render(planeId: string, textureCache: RoomTextureCache, canvas: RenderTexture, width: number, height: number, size: number, normal: IVector3D, useTexture: boolean): RenderTexture
|
||||||
{
|
{
|
||||||
const visualization = this.getPlaneVisualization(size);
|
const visualization = this.getPlaneVisualization(size);
|
||||||
|
|
||||||
@ -24,6 +25,6 @@ export class WallPlane extends Plane
|
|||||||
height = Math.round(Math.abs((_local_8.y - _local_9.y)));
|
height = Math.round(Math.abs((_local_8.y - _local_9.y)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return visualization.render(planeId, canvas, width, height, normal, useTexture);
|
return visualization.render(planeId, textureCache, canvas, width, height, normal, useTexture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { RenderTexture } from '@pixi/core';
|
import { RenderTexture } from '@pixi/core';
|
||||||
import { IAssetPlane, IVector3D } from '../../../../../../../api';
|
import { IAssetPlane, IVector3D } from '../../../../../../../api';
|
||||||
import { TextureUtils } from '../../../../../../../pixi-proxy';
|
import { RoomTextureCache } from '../../../../../../../pixi-proxy';
|
||||||
import { PlaneBitmapData } from '../../utils';
|
import { PlaneBitmapData } from '../../utils';
|
||||||
import { PlaneRasterizer } from './PlaneRasterizer';
|
import { PlaneRasterizer } from './PlaneRasterizer';
|
||||||
import { WallPlane } from './WallPlane';
|
import { WallPlane } from './WallPlane';
|
||||||
@ -36,7 +36,7 @@ export class WallRasterizer extends PlaneRasterizer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(planeId: string, canvas: RenderTexture, id: string, width: number, height: number, scale: number, normal: IVector3D, useTexture: boolean, offsetX: number = 0, offsetY: number = 0, maxX: number = 0, maxY: number = 0, timeSinceStartMs: number = 0): PlaneBitmapData
|
public render(planeId: string, textureCache: RoomTextureCache, canvas: RenderTexture, id: string, width: number, height: number, scale: number, normal: IVector3D, useTexture: boolean, offsetX: number = 0, offsetY: number = 0, maxX: number = 0, maxY: number = 0, timeSinceStartMs: number = 0): PlaneBitmapData
|
||||||
{
|
{
|
||||||
let plane = this.getPlane(id) as WallPlane;
|
let plane = this.getPlane(id) as WallPlane;
|
||||||
|
|
||||||
@ -44,9 +44,9 @@ export class WallRasterizer extends PlaneRasterizer
|
|||||||
|
|
||||||
if(!plane) return null;
|
if(!plane) return null;
|
||||||
|
|
||||||
if(canvas) TextureUtils.clearAndFillRenderTexture(canvas);
|
if(canvas) textureCache.clearAndFillRenderTexture(canvas);
|
||||||
|
|
||||||
let graphic = plane.render(planeId, canvas, width, height, scale, normal, useTexture);
|
let graphic = plane.render(planeId, textureCache, canvas, width, height, scale, normal, useTexture);
|
||||||
|
|
||||||
if(graphic && (graphic !== canvas))
|
if(graphic && (graphic !== canvas))
|
||||||
{
|
{
|
||||||
|
@ -5,25 +5,25 @@ import { Matrix, Rectangle } from '@pixi/math';
|
|||||||
import { Sprite } from '@pixi/sprite';
|
import { Sprite } from '@pixi/sprite';
|
||||||
import { PixiApplicationProxy } from './PixiApplicationProxy';
|
import { PixiApplicationProxy } from './PixiApplicationProxy';
|
||||||
|
|
||||||
export class RoomTextureUtils
|
export class RoomTextureCache
|
||||||
{
|
{
|
||||||
public static RENDER_TEXTURE_CACHE: RenderTexture[] = [];
|
public RENDER_TEXTURE_CACHE: RenderTexture[] = [];
|
||||||
|
|
||||||
public static clearCache(): void
|
public clearCache(): void
|
||||||
{
|
{
|
||||||
this.RENDER_TEXTURE_CACHE.forEach(renderTexture => renderTexture?.destroy(true));
|
this.RENDER_TEXTURE_CACHE.forEach(renderTexture => renderTexture?.destroy(true));
|
||||||
|
|
||||||
this.RENDER_TEXTURE_CACHE = [];
|
this.RENDER_TEXTURE_CACHE = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static clearRenderTexture(renderTexture: RenderTexture): RenderTexture
|
public clearRenderTexture(renderTexture: RenderTexture): RenderTexture
|
||||||
{
|
{
|
||||||
if(!renderTexture) return null;
|
if(!renderTexture) return null;
|
||||||
|
|
||||||
return this.writeToRenderTexture(new Sprite(Texture.EMPTY), renderTexture);
|
return this.writeToRenderTexture(new Sprite(Texture.EMPTY), renderTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createRenderTexture(width: number, height: number): RenderTexture
|
public createRenderTexture(width: number, height: number): RenderTexture
|
||||||
{
|
{
|
||||||
if((width < 0) || (height < 0)) return null;
|
if((width < 0) || (height < 0)) return null;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ export class RoomTextureUtils
|
|||||||
return renderTexture;
|
return renderTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createAndFillRenderTexture(width: number, height: number, color: number = 16777215): RenderTexture
|
public createAndFillRenderTexture(width: number, height: number, color: number = 16777215): RenderTexture
|
||||||
{
|
{
|
||||||
if((width < 0) || (height < 0)) return null;
|
if((width < 0) || (height < 0)) return null;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ export class RoomTextureUtils
|
|||||||
return this.clearAndFillRenderTexture(renderTexture, color);
|
return this.clearAndFillRenderTexture(renderTexture, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createAndWriteRenderTexture(width: number, height: number, displayObject: DisplayObject, transform: Matrix = null): RenderTexture
|
public createAndWriteRenderTexture(width: number, height: number, displayObject: DisplayObject, transform: Matrix = null): RenderTexture
|
||||||
{
|
{
|
||||||
if((width < 0) || (height < 0)) return null;
|
if((width < 0) || (height < 0)) return null;
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ export class RoomTextureUtils
|
|||||||
return this.writeToRenderTexture(displayObject, renderTexture, true, transform);
|
return this.writeToRenderTexture(displayObject, renderTexture, true, transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static clearAndFillRenderTexture(renderTexture: RenderTexture, color: number = 16777215): RenderTexture
|
public clearAndFillRenderTexture(renderTexture: RenderTexture, color: number = 16777215): RenderTexture
|
||||||
{
|
{
|
||||||
if(!renderTexture) return null;
|
if(!renderTexture) return null;
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ export class RoomTextureUtils
|
|||||||
return this.writeToRenderTexture(sprite, renderTexture);
|
return this.writeToRenderTexture(sprite, renderTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static writeToRenderTexture(displayObject: DisplayObject, renderTexture: RenderTexture, clear: boolean = true, transform: Matrix = null): RenderTexture
|
public writeToRenderTexture(displayObject: DisplayObject, renderTexture: RenderTexture, clear: boolean = true, transform: Matrix = null): RenderTexture
|
||||||
{
|
{
|
||||||
if(!displayObject || !renderTexture) return null;
|
if(!displayObject || !renderTexture) return null;
|
||||||
|
|
||||||
@ -82,17 +82,17 @@ export class RoomTextureUtils
|
|||||||
return renderTexture;
|
return renderTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getPixels(displayObject: DisplayObject | RenderTexture, frame: Rectangle = null): Uint8Array
|
public getPixels(displayObject: DisplayObject | RenderTexture, frame: Rectangle = null): Uint8Array
|
||||||
{
|
{
|
||||||
return this.getExtractor().pixels(displayObject);
|
return this.getExtractor().pixels(displayObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getRenderer(): Renderer | AbstractRenderer
|
public getRenderer(): Renderer | AbstractRenderer
|
||||||
{
|
{
|
||||||
return PixiApplicationProxy.instance.renderer;
|
return PixiApplicationProxy.instance.renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getExtractor(): Extract
|
public getExtractor(): Extract
|
||||||
{
|
{
|
||||||
return (this.getRenderer().plugins.extract as Extract);
|
return (this.getRenderer().plugins.extract as Extract);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user