import { observer } from "mobx-react-lite";
import type { RuntimeScene } from "../types";
import { GameObjectView } from "./GameObjectView";
import { ObjectEditorView } from "./ObjectEditorView";

type SceneViewProps = {
    scene: RuntimeScene,
    editMode?: boolean;
}

export const SceneView = observer(function (props: SceneViewProps) {
    return (<>
        <ambientLight intensity={0.5} />
        <directionalLight position={[5, 5, 5]} intensity={1} />
        {
            Object.values(props.scene.objects).map((obj) => (
                props.editMode
                    ? <ObjectEditorView key={obj.id} object={obj} isPlayer={props.scene.playerObjectId === obj.id} />
                    : <GameObjectView key={obj.id} object={obj} isPlayer={props.scene.playerObjectId === obj.id} />
            ))
        }
    </>);
});
