]> git.r.bdr.sh - rbdr/lissajous/blob - lib/factories/global.js
4f36a8e3bc96619926ecab859360a7c7ddf547fb
[rbdr/lissajous] / lib / factories / global.js
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
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 */
18 export function configuration() {
19
20 const entity = new Entity();
21 entity.addComponent(new Configuration());
22
23 return entity;
24 }
25
26 /**
27 * Creates a camera, used to modify the 3D view.
28 */
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,
36 y: Math.PI / 30,
37 z: 0,
38 }));
39 entity.addComponent(new Radius({
40 radius: 5
41 }));
42 entity.addComponent(new Up());
43
44 return entity;
45 }