From 65d5430ab00a6425791eac087536555857e1d450 Mon Sep 17 00:00:00 2001 From: cha0s Date: Mon, 11 Apr 2022 14:42:41 -0500 Subject: [PATCH] flow: ui --- .../src/persea/controllers/room/component.jsx | 27 ++-- .../controllers/room/component.module.scss | 22 +++- .../persea/room-sides/tiles-side/index.jsx | 123 +++++++++++++----- .../room-sides/tiles-side/index.module.scss | 43 +++++- 4 files changed, 172 insertions(+), 43 deletions(-) diff --git a/packages/topdown/src/persea/controllers/room/component.jsx b/packages/topdown/src/persea/controllers/room/component.jsx index 589af8b..ccc7702 100644 --- a/packages/topdown/src/persea/controllers/room/component.jsx +++ b/packages/topdown/src/persea/controllers/room/component.jsx @@ -7,6 +7,9 @@ import { Rectangle, Vector, } from '@avocado/math'; +import { + Vector as VectorComponent, +} from '@avocado/math/persea'; import { Context, redo, @@ -44,7 +47,6 @@ const RoomComponent = ({ const [side, setSide] = useState(0); const [room, setRoom] = useState(); const [roomRenderable, setRoomRenderable] = useState(); - const [viewport, setViewport] = useState([0, 0]); const roomSides = flecks.get('$avocado/topdown/persea.room-sides'); // Stage event stream. const onRef = useCallback((stage) => { @@ -54,11 +56,11 @@ const RoomComponent = ({ if (room) { const load = async () => { await Promise.all( - resource.tiles.map(async (tiles, i) => { - await room.tiles[i].load(tiles); - const {area, tileSize} = room.tiles[i]; + room.tiles.map(async (tiles, i) => { + await tiles.load(resource.tiles[i]); + const {area, tileSize} = tiles; const viewport = Vector.mul(area, tileSize); - room.tiles[i].emit('update', Rectangle.compose([0, 0], viewport)); + tiles.emit('update', Rectangle.compose([0, 0], viewport)); }), ); if (resource.entities.length !== previousResource.entities.length) { @@ -82,12 +84,9 @@ const RoomComponent = ({ uri, }); const roomRenderable = new (room.constructor.Renderable)(room, renderer); - const {area, tileSize} = room.tiles[0]; - const viewport = Vector.mul(area, tileSize); - roomRenderable.renderChunksForExtent(Rectangle.compose([0, 0], viewport)); + roomRenderable.renderChunksForExtent(Rectangle.compose([0, 0], room.size)); setRoom(room); setRoomRenderable(roomRenderable); - setViewport(viewport); }; loadRoom(); } @@ -105,7 +104,7 @@ const RoomComponent = ({ renderer={renderer} renderable={roomRenderable} scale={3} - size={viewport} + size={room.size} styles={styles} />
@@ -138,6 +137,14 @@ const RoomComponent = ({
+
+