]>
Commit | Line | Data |
---|---|---|
362f9116 RBR |
1 | import { Entity } from '@serpentity/serpentity'; |
2 | import Position from '@serpentity/components.position'; | |
3 | import EulerAngle from '@serpentity/components.euler_angle'; | |
4 | import Velocity from '@serpentity/components.velocity'; | |
5 | import Radius from '../components/radius'; | |
6 | import Up from '../components/up'; | |
7 | import Configuration from '../components/configuration'; | |
8 | ||
32e2eed2 RBR |
9 | /** |
10 | * This file is a factory for global objects. It doesn't enforce it, but | |
11 | * there should be only one of these entities in the engine at a given | |
12 | * time. | |
13 | */ | |
14 | ||
15 | /** | |
16 | * Creates a data entity that holds the configuration. | |
17 | */ | |
362f9116 RBR |
18 | export function configuration() { |
19 | ||
20 | const entity = new Entity(); | |
21 | entity.addComponent(new Configuration()); | |
22 | ||
23 | return entity; | |
24 | } | |
25 | ||
32e2eed2 RBR |
26 | /** |
27 | * Creates a camera, used to modify the 3D view. | |
28 | */ | |
362f9116 RBR |
29 | export function camera() { |
30 | ||
31 | const entity = new Entity(); | |
32 | entity.addComponent(new Position()); | |
33 | entity.addComponent(new EulerAngle()); | |
34 | entity.addComponent(new Velocity({ | |
35 | x: 0, | |
6a87c253 | 36 | y: Math.PI / 30, |
362f9116 RBR |
37 | z: 0, |
38 | })); | |
39 | entity.addComponent(new Radius({ | |
40 | radius: 5 | |
41 | })); | |
42 | entity.addComponent(new Up()); | |
43 | ||
44 | return entity; | |
45 | } |