Start working on UI

This commit is contained in:
Fuhrmann 2025-03-06 13:36:47 +01:00
parent 07208177fd
commit 8227b4141a
16 changed files with 701 additions and 581 deletions

View file

@ -1,17 +1,31 @@
"use client";
import { useEffect, useRef } from "react";
import { init } from "../three/utils/init";
import { useContext, useEffect, useRef } from "react";
import { MapScene } from "../three/MapScene";
import {
MapSceneContext,
MapSceneContextType,
} from "../providers/map-scene-provider";
export function Map() {
const divRef = useRef<HTMLDivElement>(null);
const { setMapScene } = useContext(MapSceneContext) as MapSceneContextType;
useEffect(() => {
let ignore = false;
if (!divRef.current) return;
async function loadScene() {
if (divRef.current) {
const _mapScene = await MapScene.create(divRef.current, "20");
if (_mapScene) {
setMapScene(_mapScene);
}
}
}
if (!ignore) {
init(divRef.current);
loadScene();
}
return () => {