-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
68 lines (59 loc) · 2.39 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React, {useRef, useState} from 'react';
import {AuthoringComponent} from "./components/AuthoringComponent";
import {EngineType} from "./components/engineViews/EngineType";
import {RenderIf} from "./components/RenderIf";
import {LoggingEngineComponent} from "./components/engineViews/LoggingEngineComponent";
import {BabylonEngineComponent} from "./components/engineViews/BabylonEngineComponent";
import {Tab, Tabs} from "react-bootstrap";
import {Spacer} from "./components/Spacer";
export const App = () => {
const [engineType, setEngineType] = useState<EngineType>(EngineType.BABYLON);
const [behaveGraphFromGlTF, setBehaveGraphFromGlTF] = useState<null | string>(null)
const behaveGraphRef = useRef<any>({})
return (
<div style={{width: "100vw", height: "100vh"}}>
<AuthoringComponent behaveGraphRef={behaveGraphRef} behaveGraphFromGlTF={behaveGraphFromGlTF}/>
<EngineSelector setEngineType={setEngineType}/>
<Spacer width={0} height={32}/>
<RenderIf shouldShow={engineType === EngineType.LOGGING}>
<LoggingEngineComponent behaveGraphRef={behaveGraphRef}/>
</RenderIf>
<RenderIf shouldShow={engineType === EngineType.BABYLON}>
<BabylonEngineComponent behaveGraphRef={behaveGraphRef} setBehaveGraphFromGlTF={setBehaveGraphFromGlTF}/>
</RenderIf>
</div>
);
}
interface EngineSelectorProps {
setEngineType: (engine: EngineType) => void;
}
export const EngineSelector: React.FC<EngineSelectorProps> = ({setEngineType}) => {
const [activeKey, setActiveKey] = useState('2');
const handleEngineChange = (key: any) => {
let engine;
switch (key) {
case '1':
engine = EngineType.LOGGING;
break;
case '2':
engine = EngineType.BABYLON;
break;
default:
throw Error("Invalid Selection")
}
setActiveKey(key);
setEngineType(engine);
};
return (
<div style={{width: "90vw", margin: "0 auto", textAlign: "center", marginTop: 32}}>
<h2>Behave Graph Execution</h2>
<Tabs
activeKey={activeKey}
onSelect={handleEngineChange}
>
<Tab title={"Logging Engine"} eventKey={1}/>
<Tab title={"Babylon Engine"} eventKey={2}/>
</Tabs>
</div>
);
}