1 |
|
2 |
|
3 |
|
4 |
|
5 | import 'reflect-metadata';
|
6 | import { Container } from 'inversify';
|
7 | import getDecorators from 'inversify-inject-decorators';
|
8 | import { ComponentManager } from './ComponentManager';
|
9 | import { CameraComponent } from './components/camera/CameraComponent';
|
10 | import { CameraSystem } from './components/camera/System';
|
11 | import { ComputeComponent } from './components/compute/ComputeComponent';
|
12 | import { LayoutComputeStrategy } from './components/compute/LayoutComputeStrategy';
|
13 | import { ParticleComputeStrategy } from './components/compute/ParticleComputeStrategy';
|
14 | import { ComputeSystem } from './components/compute/System';
|
15 | import { PassNodeComponent } from './components/framegraph/PassNodeComponent';
|
16 | import { ResourceHandleComponent } from './components/framegraph/ResourceHandleComponent';
|
17 | import { FrameGraphSystem } from './components/framegraph/System';
|
18 | import { GeometryComponent } from './components/geometry/GeometryComponent';
|
19 | import { GeometrySystem } from './components/geometry/System';
|
20 | import { InteractionSystem } from './components/interaction/System';
|
21 | import { MaterialComponent } from './components/material/MaterialComponent';
|
22 | import { MaterialSystem } from './components/material/System';
|
23 | import { CullableComponent } from './components/mesh/CullableComponent';
|
24 | import { MeshComponent } from './components/mesh/MeshComponent';
|
25 | import { MeshSystem } from './components/mesh/System';
|
26 | import { ForwardRenderPath } from './components/renderpath/Forward';
|
27 | import { SceneComponent } from './components/scene/SceneComponent';
|
28 | import { SceneSystem } from './components/scene/System';
|
29 | import { HierarchyComponent } from './components/scenegraph/HierarchyComponent';
|
30 | import { NameComponent } from './components/scenegraph/NameComponent';
|
31 | import { SceneGraphSystem } from './components/scenegraph/System';
|
32 | import { TransformComponent } from './components/scenegraph/TransformComponent';
|
33 | import { IDENTIFIER } from './identifier';
|
34 |
|
35 | export var container = new Container();
|
36 |
|
37 |
|
38 | var DECORATORS = getDecorators(container, false);
|
39 |
|
40 |
|
41 |
|
42 | export var lazyInject = function lazyInject(serviceIdentifier) {
|
43 | var original = DECORATORS.lazyInject(serviceIdentifier);
|
44 |
|
45 |
|
46 | return function (proto, key, descriptor) {
|
47 |
|
48 | original.call(this, proto, key);
|
49 |
|
50 | if (descriptor) {
|
51 | descriptor.initializer = function () {
|
52 | return proto[key];
|
53 | };
|
54 | }
|
55 | };
|
56 | };
|
57 | export var lazyMultiInject = function lazyMultiInject(serviceIdentifier) {
|
58 | var original = DECORATORS.lazyMultiInject(serviceIdentifier);
|
59 |
|
60 |
|
61 | return function (proto, key, descriptor) {
|
62 |
|
63 | original.call(this, proto, key);
|
64 |
|
65 | if (descriptor) {
|
66 |
|
67 | descriptor.initializer = function () {
|
68 | return proto[key];
|
69 | };
|
70 | }
|
71 | };
|
72 | };
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | container.bind(IDENTIFIER.NameComponentManager).toConstantValue(new ComponentManager(NameComponent));
|
78 | container.bind(IDENTIFIER.HierarchyComponentManager).toConstantValue(new ComponentManager(HierarchyComponent));
|
79 | container.bind(IDENTIFIER.TransformComponentManager).toConstantValue(new ComponentManager(TransformComponent));
|
80 | container.bind(IDENTIFIER.CameraComponentManager).toConstantValue(new ComponentManager(CameraComponent));
|
81 | container.bind(IDENTIFIER.ResourceHandleComponentManager).toConstantValue(new ComponentManager(ResourceHandleComponent));
|
82 | container.bind(IDENTIFIER.PassNodeComponentManager).toConstantValue(new ComponentManager(PassNodeComponent));
|
83 | container.bind(IDENTIFIER.MeshComponentManager).toConstantValue(new ComponentManager(MeshComponent));
|
84 | container.bind(IDENTIFIER.CullableComponentManager).toConstantValue(new ComponentManager(CullableComponent));
|
85 | container.bind(IDENTIFIER.GeometryComponentManager).toConstantValue(new ComponentManager(GeometryComponent));
|
86 | container.bind(IDENTIFIER.MaterialComponentManager).toConstantValue(new ComponentManager(MaterialComponent));
|
87 | container.bind(IDENTIFIER.SceneComponentManager).toConstantValue(new ComponentManager(SceneComponent));
|
88 | container.bind(IDENTIFIER.ComputeComponentManager).toConstantValue(new ComponentManager(ComputeComponent));
|
89 |
|
90 |
|
91 |
|
92 |
|
93 | container.bind(IDENTIFIER.Systems).to(SceneGraphSystem).whenTargetNamed(IDENTIFIER.SceneGraphSystem);
|
94 | container.bind(IDENTIFIER.Systems).to(SceneSystem).whenTargetNamed(IDENTIFIER.SceneSystem);
|
95 | container.bind(IDENTIFIER.Systems).to(CameraSystem).whenTargetNamed(IDENTIFIER.CameraSystem);
|
96 | container.bind(IDENTIFIER.Systems).to(FrameGraphSystem).whenTargetNamed(IDENTIFIER.FrameGraphSystem);
|
97 | container.bind(IDENTIFIER.Systems).to(MeshSystem).whenTargetNamed(IDENTIFIER.MeshSystem);
|
98 | container.bind(IDENTIFIER.Systems).to(GeometrySystem).whenTargetNamed(IDENTIFIER.GeometrySystem);
|
99 | container.bind(IDENTIFIER.Systems).to(MaterialSystem).whenTargetNamed(IDENTIFIER.MaterialSystem);
|
100 | container.bind(IDENTIFIER.Systems).to(InteractionSystem).whenTargetNamed(IDENTIFIER.InteractionSystem);
|
101 | container.bind(IDENTIFIER.Systems).to(ComputeSystem).whenTargetNamed(IDENTIFIER.ComputeSystem);
|
102 | container.bind(IDENTIFIER.ForwardRenderPath).to(ForwardRenderPath).inSingletonScope();
|
103 |
|
104 |
|
105 |
|
106 |
|
107 | container.bind(IDENTIFIER.ComputeStrategy).to(ParticleComputeStrategy).whenTargetNamed('particle');
|
108 | container.bind(IDENTIFIER.ComputeStrategy).to(LayoutComputeStrategy).whenTargetNamed('layout');
|
109 |
|
\ | No newline at end of file |