1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports.createWorldContainer = createWorldContainer;
|
9 | exports.lazyMultiInject = exports.lazyInject = exports.container = void 0;
|
10 |
|
11 | require("reflect-metadata");
|
12 |
|
13 | var _inversify = require("inversify");
|
14 |
|
15 | var _inversifyInjectDecorators = _interopRequireDefault(require("inversify-inject-decorators"));
|
16 |
|
17 | var _ComponentManager = require("./ComponentManager");
|
18 |
|
19 | var _ResourcePool = require("./components/framegraph/ResourcePool");
|
20 |
|
21 | var _System = require("./components/framegraph/System");
|
22 |
|
23 | var _GeometryComponent = require("./components/geometry/GeometryComponent");
|
24 |
|
25 | var _System2 = require("./components/geometry/System");
|
26 |
|
27 | var _MaterialComponent = require("./components/material/MaterialComponent");
|
28 |
|
29 | var _System3 = require("./components/material/System");
|
30 |
|
31 | var _CullableComponent = require("./components/mesh/CullableComponent");
|
32 |
|
33 | var _MeshComponent = require("./components/mesh/MeshComponent");
|
34 |
|
35 | var _System4 = require("./components/mesh/System");
|
36 |
|
37 | var _CopyPass = require("./components/renderer/passes/CopyPass");
|
38 |
|
39 | var _PixelPickingPass = require("./components/renderer/passes/PixelPickingPass");
|
40 |
|
41 | var _RenderPass = require("./components/renderer/passes/RenderPass");
|
42 |
|
43 | var _System5 = require("./components/renderer/System");
|
44 |
|
45 | var _HierarchyComponent = require("./components/scenegraph/HierarchyComponent");
|
46 |
|
47 | var _NameComponent = require("./components/scenegraph/NameComponent");
|
48 |
|
49 | var _System6 = require("./components/scenegraph/System");
|
50 |
|
51 | var _TransformComponent = require("./components/scenegraph/TransformComponent");
|
52 |
|
53 | var _identifier = require("./identifier");
|
54 |
|
55 | var _ConfigService = require("./services/config/ConfigService");
|
56 |
|
57 | var _IteractorService = require("./services/interactor/IteractorService");
|
58 |
|
59 | var _ShaderModuleService = _interopRequireDefault(require("./services/shader-module/ShaderModuleService"));
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | var container = new _inversify.Container();
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | exports.container = container;
|
74 | var DECORATORS = (0, _inversifyInjectDecorators.default)(container, false);
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | var lazyInject = function lazyInject(serviceIdentifier) {
|
80 | var original = DECORATORS.lazyInject(serviceIdentifier);
|
81 |
|
82 |
|
83 | return function (proto, key, descriptor) {
|
84 |
|
85 | original.call(this, proto, key);
|
86 |
|
87 | if (descriptor) {
|
88 | descriptor.initializer = function () {
|
89 | return proto[key];
|
90 | };
|
91 | }
|
92 | };
|
93 | };
|
94 |
|
95 | exports.lazyInject = lazyInject;
|
96 |
|
97 | var lazyMultiInject = function lazyMultiInject(serviceIdentifier) {
|
98 | var original = DECORATORS.lazyMultiInject(serviceIdentifier);
|
99 |
|
100 |
|
101 | return function (proto, key, descriptor) {
|
102 |
|
103 | original.call(this, proto, key);
|
104 |
|
105 | if (descriptor) {
|
106 |
|
107 | descriptor.initializer = function () {
|
108 | return proto[key];
|
109 | };
|
110 | }
|
111 | };
|
112 | };
|
113 |
|
114 |
|
115 |
|
116 | exports.lazyMultiInject = lazyMultiInject;
|
117 | container.bind(_identifier.IDENTIFIER.ShaderModuleService).to(_ShaderModuleService.default).inSingletonScope();
|
118 |
|
119 |
|
120 |
|
121 |
|
122 | container.bind(_identifier.IDENTIFIER.NameComponentManager).toConstantValue(new _ComponentManager.ComponentManager(_NameComponent.NameComponent));
|
123 | container.bind(_identifier.IDENTIFIER.HierarchyComponentManager).toConstantValue(new _ComponentManager.ComponentManager(_HierarchyComponent.HierarchyComponent));
|
124 | container.bind(_identifier.IDENTIFIER.TransformComponentManager).toConstantValue(new _ComponentManager.ComponentManager(_TransformComponent.TransformComponent));
|
125 | container.bind(_identifier.IDENTIFIER.MeshComponentManager).toConstantValue(new _ComponentManager.ComponentManager(_MeshComponent.MeshComponent));
|
126 | container.bind(_identifier.IDENTIFIER.CullableComponentManager).toConstantValue(new _ComponentManager.ComponentManager(_CullableComponent.CullableComponent));
|
127 | container.bind(_identifier.IDENTIFIER.GeometryComponentManager).toConstantValue(new _ComponentManager.ComponentManager(_GeometryComponent.GeometryComponent));
|
128 | container.bind(_identifier.IDENTIFIER.MaterialComponentManager).toConstantValue(new _ComponentManager.ComponentManager(_MaterialComponent.MaterialComponent));
|
129 |
|
130 | function createWorldContainer() {
|
131 | var worldContainer = new _inversify.Container();
|
132 | worldContainer.parent = container;
|
133 | |
134 |
|
135 |
|
136 |
|
137 | worldContainer.bind(_identifier.IDENTIFIER.Systems).to(_System6.SceneGraphSystem).inSingletonScope().whenTargetNamed(_identifier.IDENTIFIER.SceneGraphSystem);
|
138 | worldContainer.bind(_identifier.IDENTIFIER.Systems).to(_System.FrameGraphSystem).inSingletonScope().whenTargetNamed(_identifier.IDENTIFIER.FrameGraphSystem);
|
139 | worldContainer.bind(_identifier.IDENTIFIER.Systems).to(_System4.MeshSystem).inSingletonScope().whenTargetNamed(_identifier.IDENTIFIER.MeshSystem);
|
140 | worldContainer.bind(_identifier.IDENTIFIER.Systems).to(_System2.GeometrySystem).inSingletonScope().whenTargetNamed(_identifier.IDENTIFIER.GeometrySystem);
|
141 | worldContainer.bind(_identifier.IDENTIFIER.Systems).to(_System3.MaterialSystem).inSingletonScope().whenTargetNamed(_identifier.IDENTIFIER.MaterialSystem);
|
142 | worldContainer.bind(_identifier.IDENTIFIER.Systems).to(_System5.RendererSystem).inSingletonScope().whenTargetNamed(_identifier.IDENTIFIER.RendererSystem);
|
143 |
|
144 | worldContainer.bind(_identifier.IDENTIFIER.ResourcePool).to(_ResourcePool.ResourcePool).inSingletonScope();
|
145 | worldContainer.bind(_identifier.IDENTIFIER.ConfigService).to(_ConfigService.ConfigService).inSingletonScope();
|
146 | worldContainer.bind(_identifier.IDENTIFIER.InteractorService).to(_IteractorService.InteractorService).inSingletonScope();
|
147 | |
148 |
|
149 |
|
150 |
|
151 | worldContainer.bind(_identifier.IDENTIFIER.RenderPass).to(_RenderPass.RenderPass).inSingletonScope().whenTargetNamed(_RenderPass.RenderPass.IDENTIFIER);
|
152 | worldContainer.bind(_identifier.IDENTIFIER.RenderPass).to(_CopyPass.CopyPass).inSingletonScope().whenTargetNamed(_CopyPass.CopyPass.IDENTIFIER);
|
153 | worldContainer.bind(_identifier.IDENTIFIER.RenderPass).to(_PixelPickingPass.PixelPickingPass).inSingletonScope().whenTargetNamed(_PixelPickingPass.PixelPickingPass.IDENTIFIER);
|
154 | worldContainer.bind(_identifier.IDENTIFIER.RenderPassFactory).toFactory(function (context) {
|
155 | return function (name) {
|
156 | return context.container.getNamed(_identifier.IDENTIFIER.RenderPass, name);
|
157 | };
|
158 | });
|
159 | return worldContainer;
|
160 | }
|
161 |
|
\ | No newline at end of file |