]> git.r.bdr.sh - rbdr/lissajous/blame_incremental - lib/factories/global.js
Add a few comments
[rbdr/lissajous] / lib / factories / global.js
... / ...
CommitLineData
1import { Entity } from '@serpentity/serpentity';
2import Position from '@serpentity/components.position';
3import EulerAngle from '@serpentity/components.euler_angle';
4import Velocity from '@serpentity/components.velocity';
5import Radius from '../components/radius';
6import Up from '../components/up';
7import 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 */
18export 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 */
29export 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}