mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-22 23:50:52 +01:00
Update screenshot code
This commit is contained in:
parent
67c9c58570
commit
2b1e75b06f
@ -86,7 +86,7 @@ export interface IRoomEngine extends INitroManager
|
||||
processRoomObjectOperation(objectId: number, category: number, operation: string): boolean;
|
||||
processRoomObjectPlacement(placementSource: string, id: number, category: number, typeId: number, legacyString?: string, stuffData?: IObjectData, state?: number, frameNumber?: number, posture?: string): boolean;
|
||||
dispatchMouseEvent(canvasId: number, x: number, y: number, type: string, altKey: boolean, ctrlKey: boolean, shiftKey: boolean, buttonDown: boolean): void;
|
||||
createRoomScreenshot(roomId: number, canvasId: number): void;
|
||||
createRoomScreenshot(roomId: number, canvasId?: number, bounds?: Rectangle): void;
|
||||
modifyRoomObjectData(objectId: number, objectCategory: number, colorHex: string, text: string): boolean;
|
||||
deleteRoomObject(objectId: number, objectCategory: number): boolean;
|
||||
sessionDataManager: ISessionDataManager;
|
||||
|
@ -6,6 +6,7 @@ import { NitroManager } from '../../core/common/NitroManager';
|
||||
import { IConnection } from '../../core/communication/connections/IConnection';
|
||||
import { IMessageComposer } from '../../core/communication/messages/IMessageComposer';
|
||||
import { NitroEvent } from '../../core/events/NitroEvent';
|
||||
import { TextureUtils } from '../../room';
|
||||
import { RoomObjectEvent } from '../../room/events/RoomObjectEvent';
|
||||
import { RoomObjectMouseEvent } from '../../room/events/RoomObjectMouseEvent';
|
||||
import { IRoomInstance } from '../../room/IRoomInstance';
|
||||
@ -3437,17 +3438,32 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
return null;
|
||||
}
|
||||
|
||||
public createRoomScreenshot(roomId: number, canvasId: number): void
|
||||
public createRoomScreenshot(roomId: number, canvasId: number = -1, bounds: Rectangle = null): void
|
||||
{
|
||||
const canvas = this.getRoomInstanceRenderingCanvas(roomId, canvasId);
|
||||
let canvas: IRoomRenderingCanvas = null;
|
||||
|
||||
if(!canvas) return;
|
||||
if(canvasId > -1)
|
||||
{
|
||||
canvas = this.getRoomInstanceRenderingCanvas(this._activeRoomId, canvasId);
|
||||
}
|
||||
else
|
||||
{
|
||||
canvas = this.getActiveRoomInstanceRenderingCanvas();
|
||||
}
|
||||
|
||||
const texture = canvas.getDisplayAsTexture();
|
||||
let texture: RenderTexture = null;
|
||||
|
||||
const base64 = Nitro.instance.renderer.extract.base64(texture);
|
||||
if(bounds)
|
||||
{
|
||||
texture = TextureUtils.generateTexture(canvas.master, bounds);
|
||||
}
|
||||
else
|
||||
{
|
||||
texture = canvas.getDisplayAsTexture();
|
||||
}
|
||||
|
||||
const image = new Image();
|
||||
const base64 = TextureUtils.generateImageUrl(texture);
|
||||
const image = new Image();
|
||||
|
||||
image.src = base64;
|
||||
|
||||
|
4
src/room/utils/NitroRectangle.ts
Normal file
4
src/room/utils/NitroRectangle.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { Rectangle } from 'pixi.js';
|
||||
|
||||
export class NitroRectangle extends Rectangle
|
||||
{}
|
@ -3,6 +3,7 @@ export * from './INitroPoint';
|
||||
export * from './IRoomGeometry';
|
||||
export * from './IVector3D';
|
||||
export * from './NitroPoint';
|
||||
export * from './NitroRectangle';
|
||||
export * from './NumberBank';
|
||||
export * from './PointMath';
|
||||
export * from './Rasterizer';
|
||||
|
Loading…
Reference in New Issue
Block a user