-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature-three' into main
- Loading branch information
Showing
6 changed files
with
152 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,8 @@ | ||
import Layout from "./three/Layout"; | ||
import { ThreeProvider } from "./three"; | ||
import useLayoutGeometry from "./three/useLayoutGeometry"; | ||
import NavMesh from "./three/NavMesh"; | ||
|
||
const wallConfig = { | ||
wallThickness: 0.4, | ||
width: 20, | ||
length: 20, | ||
wallHeight: 1, | ||
}; | ||
|
||
const walls = [ | ||
[ | ||
[1, -9.75], | ||
[1, 1.2], | ||
], | ||
[ | ||
[-4.6, 1.2], | ||
[1.02, 1.2], | ||
], | ||
[ | ||
[-9.55, 1.2], | ||
[-7.1, 1.2], | ||
], | ||
[ | ||
[4, -9.75], | ||
[4, -4], | ||
], | ||
[ | ||
[4, -0.6], | ||
[4, 0.75], | ||
], | ||
[ | ||
[4, 0.55], | ||
[8.34, 0.55], | ||
], | ||
[ | ||
[-9.65, 8.5], | ||
[-6.8, 8.5], | ||
], | ||
[ | ||
[-3.75, 8.5], | ||
[2.5, 8.5], | ||
], | ||
[ | ||
[5.55, 8.5], | ||
[8.34, 8.5], | ||
], | ||
[ | ||
[-9.9, -9.75], | ||
[1.2, -9.75], | ||
], | ||
[ | ||
[3.8, -9.75], | ||
[8.7, -9.75], | ||
], | ||
[ | ||
[-9.7, -9.75], | ||
[-9.7, 8.7], | ||
], | ||
[ | ||
[8.5, -9.75], | ||
[8.5, 8.7], | ||
], | ||
].map( | ||
([start, end]) => | ||
[ | ||
[start[0], 0, start[1]], | ||
[end[0], wallConfig.wallHeight, end[1]], | ||
] as [number[], number[]] | ||
); | ||
import ThreeApp from "./ThreeApp"; | ||
import { wallConfig, walls } from "./data"; | ||
|
||
const App = () => { | ||
const geometry = useLayoutGeometry({ | ||
...wallConfig, | ||
walls, | ||
}); | ||
|
||
return ( | ||
<ThreeProvider> | ||
<Layout geometry={geometry} {...wallConfig} /> | ||
<NavMesh geometry={geometry} wallThickness={wallConfig.wallThickness} /> | ||
</ThreeProvider> | ||
); | ||
return <ThreeApp wallConfig={wallConfig} walls={walls} />; | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Layout from "./three/Layout"; | ||
import { ThreeProvider } from "./three"; | ||
import NavMesh from "./three/NavMesh"; | ||
import { WallConfig, Walls } from "./data"; | ||
|
||
interface ThreeAppProps { | ||
wallConfig: WallConfig; | ||
walls: Walls; | ||
} | ||
|
||
const ThreeApp = ({ wallConfig, walls }: ThreeAppProps) => { | ||
return ( | ||
<ThreeProvider> | ||
<Layout wallConfig={wallConfig} walls={walls} /> | ||
<NavMesh wallConfig={wallConfig} walls={walls} /> | ||
</ThreeProvider> | ||
); | ||
}; | ||
|
||
export default ThreeApp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
type Vector3Pair = [number[], number[]]; | ||
|
||
export type Walls = Array<Vector3Pair>; | ||
export interface WallConfig { | ||
width: number; | ||
length: number; | ||
wallThickness: number; | ||
wallHeight: number; | ||
} | ||
|
||
const wallConfig: WallConfig = { | ||
wallThickness: 0.4, | ||
width: 20, | ||
length: 20, | ||
wallHeight: 1, | ||
}; | ||
|
||
const walls: Walls = [ | ||
[ | ||
[1, -9.75], | ||
[1, 1.2], | ||
], | ||
[ | ||
[-4.6, 1.2], | ||
[1.02, 1.2], | ||
], | ||
[ | ||
[-9.55, 1.2], | ||
[-7.1, 1.2], | ||
], | ||
[ | ||
[4, -9.75], | ||
[4, -4], | ||
], | ||
[ | ||
[4, -0.6], | ||
[4, 0.75], | ||
], | ||
[ | ||
[4, 0.55], | ||
[8.34, 0.55], | ||
], | ||
[ | ||
[-9.65, 8.5], | ||
[-6.8, 8.5], | ||
], | ||
[ | ||
[-3.75, 8.5], | ||
[2.5, 8.5], | ||
], | ||
[ | ||
[5.55, 8.5], | ||
[8.34, 8.5], | ||
], | ||
[ | ||
[-9.9, -9.75], | ||
[1.2, -9.75], | ||
], | ||
[ | ||
[3.8, -9.75], | ||
[8.7, -9.75], | ||
], | ||
[ | ||
[-9.7, -9.75], | ||
[-9.7, 8.7], | ||
], | ||
[ | ||
[8.5, -9.75], | ||
[8.5, 8.7], | ||
], | ||
].map( | ||
([start, end]) => | ||
[ | ||
[start[0], 0, start[1]], | ||
[end[0], wallConfig.wallHeight, end[1]], | ||
] as [number[], number[]] | ||
); | ||
|
||
export { wallConfig, walls }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import App from "../App"; | ||
import ThreeApp from "../ThreeApp"; | ||
import { wallConfig, walls } from "../data"; | ||
|
||
const meta = { | ||
title: "App", | ||
component: App, | ||
} satisfies Meta<typeof App>; | ||
title: "ThreeApp", | ||
component: ThreeApp, | ||
} satisfies Meta<typeof ThreeApp>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Playground: Story = { | ||
args: {}, | ||
args: { | ||
wallConfig, | ||
walls, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters