diff --git a/src/common/layout/LayoutRoomPreviewerView.tsx b/src/common/layout/LayoutRoomPreviewerView.tsx index dd31fd6e..66969086 100644 --- a/src/common/layout/LayoutRoomPreviewerView.tsx +++ b/src/common/layout/LayoutRoomPreviewerView.tsx @@ -32,24 +32,24 @@ export const LayoutRoomPreviewerView: FC = 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 = props = update(GetTicker()); }); - roomPreviewer.getRoomCanvas(width, height); - resizeObserver.observe(elementRef.current); return () => diff --git a/src/hooks/rooms/useRoom.ts b/src/hooks/rooms/useRoom.ts index 74967461..2f2a1343 100644 --- a/src/hooks/rooms/useRoom.ts +++ b/src/hooks/rooms/useRoom.ts @@ -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);