Floor updates

This commit is contained in:
Bill 2021-09-07 21:05:14 -04:00
parent 296ecf4722
commit 6b11516ee8
7 changed files with 146 additions and 185 deletions

View File

@ -71,11 +71,11 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
}
}
public render(k: Graphics, _arg_2: number, _arg_3: number, _arg_4: IVector3D, _arg_5: number, _arg_6: number, _arg_7: number, _arg_8: number, _arg_9: number, _arg_10: number, _arg_11: number): Graphics
public render(canvas: Graphics, width: number, height: number, normal: IVector3D, offsetX: number, offsetY: number, maxX: number, maxY: number, dimensionX: number, dimensionY: number, timeSinceStartMs: number): Graphics
{
if((((k == null) || (!(k.width == _arg_2))) || (!(k.height == _arg_3))))
if((((canvas == null) || (!(canvas.width == width))) || (!(canvas.height == height))))
{
if((((this._bitmapData == null) || (!(this._bitmapData.width == _arg_2))) || (!(this._bitmapData.height == _arg_3))))
if((((this._bitmapData == null) || (!(this._bitmapData.width == width))) || (!(this._bitmapData.height == height))))
{
if(this._bitmapData != null)
{
@ -83,7 +83,7 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
}
this._bitmapData = new Graphics()
.drawRect(0, 0, _arg_2, _arg_3);
.drawRect(0, 0, width, height);
}
else
{
@ -94,10 +94,10 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
//this._bitmapData.fillRect(this._bitmapData.rect, 0xFFFFFF);
}
k = this._bitmapData;
canvas = this._bitmapData;
}
if(((_arg_7 > 0) && (_arg_8 > 0)))
if(((maxX > 0) && (maxY > 0)))
{
let _local_12 = 0;
@ -106,16 +106,16 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
const _local_13 = (this._items[_local_12] as AnimationItem);
if(_local_13 != null)
{
const _local_14 = _local_13.getPosition(_arg_7, _arg_8, _arg_9, _arg_10, _arg_11);
const _local_14 = _local_13.getPosition(maxX, maxY, dimensionX, dimensionY, timeSinceStartMs);
_local_14.x = (_local_14.x - _arg_5);
_local_14.y = (_local_14.y - _arg_6);
_local_14.x = (_local_14.x - offsetX);
_local_14.y = (_local_14.y - offsetY);
if(_local_13.bitmapData)
{
if(_local_14.x > 0 && (_local_14.x + _local_13.bitmapData.width < k.width))
if(_local_14.x > 0 && (_local_14.x + _local_13.bitmapData.width < canvas.width))
{
k
canvas
.beginFill(0x00FF00)
.beginTextureFill({ texture: _local_13.bitmapData.texture, matrix: new Matrix(1, 0, 0, 1, _local_14.x, _local_14.y) })
.drawRect(_local_14.x, _local_14.y, _local_13.bitmapData.width, _local_13.bitmapData.height)
@ -123,8 +123,8 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
}
else if(_local_14.x > 0)
{
const difference = k.width - _local_14.x;
k
const difference = canvas.width - _local_14.x;
canvas
.beginFill(0x00FF00)
.beginTextureFill({ texture: _local_13.bitmapData.texture, matrix: new Matrix(1, 0, 0, 1, _local_14.x, _local_14.y) })
.drawRect(_local_14.x, _local_14.y, difference, _local_13.bitmapData.height)
@ -134,7 +134,7 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
{
//if(_local_14.x > -_local_13.bitmapData.width)
const difference = _local_13.bitmapData.width + _local_14.x;
k
canvas
.beginFill(0x00FF00)
.beginTextureFill({ texture: _local_13.bitmapData.texture, matrix: new Matrix(1, 0, 0, 1, _local_14.x, _local_14.y) })
.drawRect(0, _local_14.y, difference, _local_13.bitmapData.height)
@ -147,6 +147,6 @@ export class PlaneVisualizationAnimationLayer implements IDisposable
}
}
return k;
return canvas;
}
}

View File

@ -19,8 +19,8 @@ export class FloorPlane extends Plane
const _local_11 = visualization.geometry.getScreenPoint(new Vector3d(0, (height / visualization.geometry.scale), 0));
const _local_12 = visualization.geometry.getScreenPoint(new Vector3d((width / visualization.geometry.scale), 0, 0));
let _local_13 = 0;
let _local_14 = 0;
let x = 0;
let y = 0;
if(_local_10 && _local_11 && _local_12)
{
@ -29,10 +29,10 @@ export class FloorPlane extends Plane
const _local_15 = (_local_10.x - visualization.geometry.getScreenPoint(new Vector3d(1, 0, 0)).x);
_local_13 = (offsetX * Math.trunc(Math.abs(_local_15)));
_local_14 = (offsetY * Math.trunc(Math.abs(_local_15)));
x = (offsetX * Math.trunc(Math.abs(_local_15)));
y = (offsetY * Math.trunc(Math.abs(_local_15)));
}
return visualization.render(canvas, width, height, normal, useTexture, _local_13, _local_14);
return visualization.render(canvas, width, height, normal, useTexture, x, y);
}
}

View File

@ -43,13 +43,7 @@ export class FloorRasterizer extends PlaneRasterizer
if(!plane) return null;
if(canvas)
{
canvas
.beginFill(0xFFFFFF)
.drawRect(0, 0, canvas.width, canvas.height)
.endFill();
}
if(canvas) canvas.clear();
let graphic = plane.render(canvas, width, height, scale, normal, useTexture, offsetX, offsetY);

View File

@ -1,15 +1,13 @@
import { Graphics } from '@pixi/graphics';
import { Point } from '@pixi/math';
import { Sprite } from '@pixi/sprite';
import { TilingSprite } from '@pixi/sprite-tiling';
import { Matrix, Point } from '@pixi/math';
import { NitroSprite } from '../../../../../../../core';
import { IGraphicAsset } from '../../../../../../../room/object/visualization/utils/IGraphicAsset';
import { IVector3D } from '../../../../../../../room/utils/IVector3D';
import { Randomizer } from '../../utils';
import { PlaneTexture } from './PlaneTexture';
export class PlaneMaterialCell
{
private _cachedBitmapData: Graphics;
private _cachedSprite: NitroSprite;
private _texture: PlaneTexture;
private _extraItemOffsets: Point[];
private _extraItemAssets: IGraphicAsset[];
@ -17,7 +15,7 @@ export class PlaneMaterialCell
constructor(texture: PlaneTexture, assets: IGraphicAsset[] = null, offsetPoints: Point[] = null, limit: number = 0)
{
this._cachedBitmapData = null;
this._cachedSprite = null;
this._texture = texture;
this._extraItemOffsets = [];
this._extraItemAssets = [];
@ -71,11 +69,11 @@ export class PlaneMaterialCell
this._texture = null;
}
if(this._cachedBitmapData)
if(this._cachedSprite)
{
this._cachedBitmapData.destroy();
this._cachedSprite.destroy();
this._cachedBitmapData = null;
this._cachedSprite = null;
}
this._extraItemAssets = null;
@ -85,11 +83,11 @@ export class PlaneMaterialCell
public clearCache(): void
{
if(this._cachedBitmapData)
if(this._cachedSprite)
{
this._cachedBitmapData.destroy();
this._cachedSprite.destroy();
this._cachedBitmapData = null;
this._cachedSprite = null;
}
}
@ -105,7 +103,7 @@ export class PlaneMaterialCell
return 0;
}
public render(normal: IVector3D, textureOffsetX: number, textureOffsetY: number): Sprite
public render(normal: IVector3D, textureOffsetX: number, textureOffsetY: number): NitroSprite
{
if(!this._texture) return null;
@ -113,7 +111,7 @@ export class PlaneMaterialCell
if(!texture) return null;
let bitmap: Sprite = null;
const bitmap = new NitroSprite(texture);
if((textureOffsetX !== 0) || (textureOffsetY !== 0))
{
@ -121,117 +119,100 @@ export class PlaneMaterialCell
while(textureOffsetY < 0) textureOffsetY += texture.height;
const tiling = new TilingSprite(texture, texture.width, texture.height);
tiling.tilePosition.x = (textureOffsetX % texture.width);
tiling.tilePosition.y = (textureOffsetY % texture.height);
tiling.uvRespectAnchor = true;
bitmap.x = (textureOffsetX % texture.width);
bitmap.y = (textureOffsetY % texture.height);
if(textureOffsetX)
{
tiling.anchor.x = 1;
tiling.scale.x = -1;
bitmap.anchor.x = 1;
bitmap.scale.x = -1;
}
if(textureOffsetY)
{
tiling.anchor.y = 1;
tiling.scale.y = -1;
bitmap.anchor.y = 1;
bitmap.scale.y = -1;
}
bitmap = tiling;
}
else
{
bitmap = new NitroSprite(texture);
}
if(bitmap)
{
// if(!this.isStatic)
// {
// if(this._cachedBitmapData)
// {
// if((this._cachedBitmapData.width !== bitmap.width) || (this._cachedBitmapData.height !== bitmap.height))
// {
// this._cachedBitmapData.destroy();
if(!this.isStatic)
{
if(this._cachedSprite)
{
if((this._cachedSprite.width !== bitmap.width) || (this._cachedSprite.height !== bitmap.height))
{
this._cachedSprite.destroy();
// this._cachedBitmapData = null;
// }
// else
// {
// const bitmapTexture = TextureUtils.generateTexture(bitmap, new Rectangle(0, 0, bitmap.width, bitmap.height));
this._cachedSprite = null;
}
}
// RoomVisualization.RENDER_TEXTURES.push(bitmapTexture);
if(!this._cachedSprite)
{
this._cachedSprite = new NitroSprite(texture);
}
// if(bitmapTexture)
// {
// this._cachedBitmapData
// .beginTextureFill({ texture: bitmapTexture })
// .drawRect(0, 0, bitmapTexture.width, bitmapTexture.height)
// .endFill();
// }
// }
// }
const limitMin = Math.min(this._extraItemCount, this._extraItemOffsets.length);
const limitMax = Math.max(this._extraItemCount, this._extraItemOffsets.length);
const offsetIndexes = Randomizer.getArray(this._extraItemCount, limitMax);
// if(!this._cachedBitmapData) this._cachedBitmapData = bitmap.clone();
let i = 0;
// const limitMin = Math.min(this._extraItemCount, this._extraItemOffsets.length);
// const limitMax = Math.max(this._extraItemCount, this._extraItemOffsets.length);
// const offsetIndexes = Randomizer.getArray(this._extraItemCount, limitMax);
while(i < limitMin)
{
const offset = this._extraItemOffsets[offsetIndexes[i]];
const item = this._extraItemAssets[(i % this._extraItemAssets.length)];
// let i = 0;
if(offset && item)
{
const assetTexture = item.texture;
// while (i < limitMin)
// {
// const offset = this._extraItemOffsets[offsetIndexes[i]];
// const item = this._extraItemAssets[(i % this._extraItemAssets.length)];
if(assetTexture)
{
const offsetFinal = new Point((offset.x + item.offsetX), (offset.y + item.offsetY));
const flipMatrix = new Matrix();
// if(offset && item)
// {
// const assetTexture = item.texture;
let x = 1;
let y = 1;
let translateX = 0;
let translateY = 0;
// if(assetTexture)
// {
// const offsetFinal = new Point((offset.x + item.offsetX), (offset.y + item.offsetY));
// const flipMatrix = new Matrix();
if(item.flipH)
{
x = -1;
translateX = assetTexture.width;
}
// let x = 1;
// let y = 1;
// let translateX = 0;
// let translateY = 0;
if(item.flipV)
{
y = -1;
translateY = assetTexture.height;
}
// if(item.flipH)
// {
// x = -1;
// translateX = assetTexture.width;
// }
let offsetX = (offsetFinal.x + translateX);
offsetX = ((offsetX >> 1) << 1);
// if(item.flipV)
// {
// y = -1;
// translateY = assetTexture.height;
// }
flipMatrix.scale(x, y);
flipMatrix.translate(offsetX, (offsetFinal.y + translateY));
// let offsetX = (offsetFinal.x + translateX);
// offsetX = ((offsetX >> 1) << 1);
const sprite = new NitroSprite(assetTexture);
// flipMatrix.scale(x, y);
// flipMatrix.translate(offsetX, (offsetFinal.y + translateY));
sprite.transform.setFromMatrix(flipMatrix);
// this._cachedBitmapData
// .beginTextureFill({ texture: assetTexture, matrix: flipMatrix })
// .drawRect(flipMatrix.tx, flipMatrix.ty, assetTexture.width, assetTexture.height)
// .endFill();
// }
// }
sprite.x = flipMatrix.tx;
sprite.y = flipMatrix.ty;
// i++;
// }
this._cachedSprite.addChild(sprite);
}
}
// return this._cachedBitmapData;
// }
i++;
}
return this._cachedSprite;
}
return bitmap;
}

View File

@ -1,4 +1,5 @@
import { Graphics } from '@pixi/graphics';
import { NitroRenderTexture } from '../../../../../../../core';
import { IVector3D } from '../../../../../../../room/utils/IVector3D';
import { Vector3d } from '../../../../../../../room/utils/Vector3d';
import { PlaneMaterialCell } from './PlaneMaterialCell';
@ -15,6 +16,7 @@ export class PlaneMaterialCellColumn
private _cells: PlaneMaterialCell[];
private _repeatMode: number;
private _width: number;
private _cachedTexture: NitroRenderTexture;
private _cachedBitmapData: Graphics;
private _cachedBitmapNormal: Vector3d;
private _cachedBitmapDataOffsetX: number;
@ -192,19 +194,19 @@ export class PlaneMaterialCellColumn
this.renderRepeatNone(normal);
break;
case PlaneMaterialCellColumn.REPEAT_MODE_BORDERS:
console.log('tru2');
console.log('REPEAT_MODE_BORDERS');
// this.renderRepeatBorders(normal);
break;
case PlaneMaterialCellColumn.REPEAT_MODE_CENTER:
console.log('tru3');
console.log('REPEAT_MODE_CENTER');
// this.renderRepeatCenter(normal);
break;
case PlaneMaterialCellColumn.REPEAT_MODE_FIRST:
console.log('tru4');
console.log('REPEAT_MODE_FIRST');
// this.renderRepeatFirst(normal);
break;
case PlaneMaterialCellColumn.REPEAT_MODE_LAST:
console.log('tru5');
console.log('REPEAT_MODE_LAST');
// this.renderRepeatLast(normal);
break;
default:

View File

@ -362,59 +362,43 @@ export class PlaneMaterialCellMatrix
if(!canvas || !columns || !columns.length) return new Point(x, 0);
let height = 0;
let _local_6: Graphics = null;
let _local_7 = 0;
let i = 0;
while(_local_7 < columns.length)
while(i < columns.length)
{
if(flag)
{
_local_6 = columns[_local_7];
}
else
{
_local_6 = columns[((columns.length - 1) - _local_7)];
}
if(_local_6 != null)
{
if(!flag)
{
x = (x - _local_6.width);
}
let _local_8 = 0;
if(this._align == PlaneMaterialCellMatrix.ALIGN_BOTTOM)
{
_local_8 = (canvas.height - _local_6.height);
}
const column = flag ? columns[i] : columns[((columns.length - 1) - i)];
let texture = RoomVisualization.getTextureCache(_local_6);
if(column)
{
if(!flag) x = (x - column.width);
let y = 0;
if(this._align == PlaneMaterialCellMatrix.ALIGN_BOTTOM) y = (canvas.height - column.height);
let texture = RoomVisualization.getTextureCache(column);
if(!texture)
{
texture = TextureUtils.generateTexture(_local_6, new Rectangle(0, 0, _local_6.width, _local_6.height));
texture = TextureUtils.generateTexture(column, new Rectangle(0, 0, column.width, column.height));
RoomVisualization.addTextureCache(_local_6, texture);
RoomVisualization.addTextureCache(column, texture);
}
canvas.beginTextureFill({ texture });
canvas.drawRect(x, _local_8, texture.width, texture.height);
canvas.drawRect(x, y, texture.width, texture.height);
canvas.endFill();
if(_local_6.height > height)
{
height = _local_6.height;
}
if(flag)
{
x = (x + _local_6.width);
}
if((((flag) && (x >= canvas.width)) || ((!(flag)) && (x <= 0))))
{
return new Point(x, height);
}
if(column.height > height) height = column.height;
if(flag) x = (x + column.width);
if((flag && (x >= canvas.width)) || (!flag && (x <= 0))) return new Point(x, height);
}
_local_7++;
i++;
}
return new Point(x, height);
}

View File

@ -1,10 +1,8 @@
import { Graphics } from '@pixi/graphics';
import { Rectangle } from '@pixi/math';
import { IDisposable } from '../../../../../../../core/common/disposable/IDisposable';
import { IGraphicAssetCollection } from '../../../../../../../room/object/visualization/utils/IGraphicAssetCollection';
import { IRoomGeometry } from '../../../../../../../room/utils/IRoomGeometry';
import { IVector3D } from '../../../../../../../room/utils/IVector3D';
import { TextureUtils } from '../../../../../../../room/utils/TextureUtils';
import { Vector3d } from '../../../../../../../room/utils/Vector3d';
import { PlaneVisualizationAnimationLayer } from '../animated/PlaneVisualizationAnimationLayer';
import { PlaneMaterial } from './PlaneMaterial';
@ -159,17 +157,20 @@ export class PlaneVisualization
{
if(canvas)
{
const texture = TextureUtils.generateTexture(this._cachedBitmapData, new Rectangle(0, 0, width, height));
canvas.addChild(this._cachedBitmapData);
if(texture)
{
canvas
.beginTextureFill({ texture })
.drawRect(0, 0, texture.width, texture.height)
.endFill();
return canvas;
// const texture = TextureUtils.generateTexture(this._cachedBitmapData, new Rectangle(0, 0, width, height));
return canvas;
}
// if(texture)
// {
// canvas
// .beginTextureFill({ texture })
// .drawRect(0, 0, texture.width, texture.height)
// .endFill();
// return canvas;
// }
}
return this._cachedBitmapData;
@ -187,12 +188,10 @@ export class PlaneVisualization
if(!this._cachedBitmapData)
{
const graphic = new Graphics()
this._cachedBitmapData = new Graphics()
.beginFill(0xFFFFFF)
.drawRect(0, 0, width, height)
.endFill();
this._cachedBitmapData = graphic;
}
else
{
@ -226,12 +225,13 @@ export class PlaneVisualization
if(canvas && (canvas !== this._cachedBitmapData))
{
const texture = TextureUtils.generateTexture(canvas, new Rectangle(0, 0, canvas.width, canvas.height));
this._cachedBitmapData.addChild(canvas.clone());
// const texture = TextureUtils.generateTexture(canvas, new Rectangle(0, 0, canvas.width, canvas.height));
this._cachedBitmapData
.beginTextureFill({ texture })
.drawRect(0, 0, canvas.width, canvas.height)
.endFill();
// this._cachedBitmapData
// .beginTextureFill({ texture })
// .drawRect(0, 0, canvas.width, canvas.height)
// .endFill();
return canvas;
}