This commit is contained in:
Bill 2024-06-24 15:48:38 -04:00
parent 0db9e4ad45
commit 23f6bdbf4b
2 changed files with 11 additions and 13 deletions

View File

@ -32,24 +32,24 @@ export const LayoutRoomPreviewerView: FC<LayoutRoomPreviewerViewProps> = props =
{
if(!roomPreviewer || !elementRef.current) return;
roomPreviewer.updatePreviewRoomView();
const canvas = roomPreviewer.getRoomCanvas(width, height);
const renderingCanvas = roomPreviewer.getRenderingCanvas();
if(!renderingCanvas.canvasUpdated) return;
roomPreviewer.updatePreviewRoomView();
GetRenderer().render({
target: texture,
container: renderingCanvas.master,
container: canvas,
clear: true
});
let canvas = GetRenderer().texture.generateCanvas(texture);
const base64 = canvas.toDataURL('image/png');
const url = await TextureUtils.generateImageUrl(texture);
canvas = null;
if(!elementRef || !elementRef.current) return;
elementRef.current.style.backgroundImage = `url(${ base64 })`;
elementRef.current.style.backgroundImage = `url(${ url })`;
};
GetTicker().add(update);
@ -65,8 +65,6 @@ export const LayoutRoomPreviewerView: FC<LayoutRoomPreviewerViewProps> = props =
update(GetTicker());
});
roomPreviewer.getRoomCanvas(width, height);
resizeObserver.observe(elementRef.current);
return () =>

View File

@ -204,7 +204,7 @@ const useRoomState = () =>
const height = Math.floor(window.innerHeight);
const renderer = GetRenderer();
if(renderer) renderer.resize(width, height);
if(renderer) renderer.resize(width, height, window.devicePixelRatio);
const displayObject = roomEngine.getRoomInstanceDisplay(roomId, canvasId, width, height, RoomGeometry.SCALE_ZOOMED_IN);
const canvas = GetRoomEngine().getRoomInstanceRenderingCanvas(roomId, canvasId);
@ -256,13 +256,13 @@ const useRoomState = () =>
const width = Math.floor(window.innerWidth);
const height = Math.floor(window.innerHeight);
renderer.resolution = window.devicePixelRatio;
renderer.resize(width, height);
background.width = width;
background.height = height;
renderer.resize(width, height, window.devicePixelRatio);
InitializeRoomInstanceRenderingCanvas(width, height, 1);
GetRenderer().render(GetStage());
};
window.addEventListener('resize', resize);