2019-12-22 02:40:42 +08:00
|
|
|
import { ViewerView } from "./gui/ViewerView";
|
|
|
|
import { GuiStore } from "../core/stores/GuiStore";
|
2019-12-22 05:49:41 +08:00
|
|
|
import { HttpClient } from "../core/HttpClient";
|
2019-12-22 07:43:27 +08:00
|
|
|
import { DisposableThreeRenderer } from "../core/rendering/Renderer";
|
2019-12-25 07:17:02 +08:00
|
|
|
import { Disposable } from "../core/observable/Disposable";
|
|
|
|
import { Disposer } from "../core/observable/Disposer";
|
2020-01-06 01:40:35 +08:00
|
|
|
import { TextureRenderer } from "./rendering/TextureRenderer";
|
|
|
|
import { ModelRenderer } from "./rendering/ModelRenderer";
|
|
|
|
import { Random } from "../core/Random";
|
|
|
|
import { ModelToolBarView } from "./gui/model/ModelToolBarView";
|
|
|
|
import { ModelStore } from "./stores/ModelStore";
|
|
|
|
import { ModelToolBarController } from "./controllers/model/ModelToolBarController";
|
|
|
|
import { CharacterClassOptionsView } from "./gui/model/CharacterClassOptionsView";
|
|
|
|
import { CharacterClassOptionsController } from "./controllers/model/CharacterClassOptionsController";
|
2019-12-22 02:40:42 +08:00
|
|
|
|
2019-12-22 07:43:27 +08:00
|
|
|
export function initialize_viewer(
|
|
|
|
http_client: HttpClient,
|
2020-01-06 01:40:35 +08:00
|
|
|
random: Random,
|
2019-12-22 07:43:27 +08:00
|
|
|
gui_store: GuiStore,
|
|
|
|
create_three_renderer: () => DisposableThreeRenderer,
|
2019-12-25 07:17:02 +08:00
|
|
|
): { view: ViewerView } & Disposable {
|
|
|
|
const disposer = new Disposer();
|
|
|
|
|
|
|
|
const view = new ViewerView(
|
2020-01-05 08:07:35 +08:00
|
|
|
gui_store,
|
2020-01-06 01:40:35 +08:00
|
|
|
|
2019-12-22 02:40:42 +08:00
|
|
|
async () => {
|
2020-01-06 01:40:35 +08:00
|
|
|
const { ModelController } = await import("./controllers/model/ModelController");
|
|
|
|
const { ModelView } = await import("./gui/model/ModelView");
|
2019-12-22 05:49:41 +08:00
|
|
|
const { CharacterClassAssetLoader } = await import(
|
|
|
|
"./loading/CharacterClassAssetLoader"
|
|
|
|
);
|
2020-01-02 03:15:39 +08:00
|
|
|
const asset_loader = disposer.add(new CharacterClassAssetLoader(http_client));
|
2020-01-06 05:40:26 +08:00
|
|
|
const store = disposer.add(new ModelStore(gui_store, asset_loader, random));
|
2020-01-06 01:40:35 +08:00
|
|
|
const model_controller = new ModelController(store);
|
|
|
|
const model_tool_bar_controller = new ModelToolBarController(store);
|
|
|
|
const character_class_options_controller = new CharacterClassOptionsController(store);
|
2019-12-25 07:17:02 +08:00
|
|
|
|
2020-01-06 01:40:35 +08:00
|
|
|
return new ModelView(
|
|
|
|
model_controller,
|
|
|
|
new ModelToolBarView(model_tool_bar_controller),
|
|
|
|
new CharacterClassOptionsView(character_class_options_controller),
|
|
|
|
new ModelRenderer(store, create_three_renderer()),
|
|
|
|
);
|
2019-12-22 02:40:42 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
async () => {
|
2020-01-06 01:40:35 +08:00
|
|
|
const { TextureController } = await import("./controllers/TextureController");
|
2019-12-22 02:40:42 +08:00
|
|
|
const { TextureView } = await import("./gui/TextureView");
|
2020-01-06 01:40:35 +08:00
|
|
|
const controller = disposer.add(new TextureController());
|
2019-12-25 07:17:02 +08:00
|
|
|
|
2020-01-06 01:40:35 +08:00
|
|
|
return new TextureView(
|
|
|
|
controller,
|
|
|
|
new TextureRenderer(controller, create_three_renderer()),
|
|
|
|
);
|
2019-12-22 02:40:42 +08:00
|
|
|
},
|
|
|
|
);
|
2019-12-25 07:17:02 +08:00
|
|
|
|
|
|
|
return {
|
|
|
|
view,
|
|
|
|
dispose(): void {
|
|
|
|
disposer.dispose();
|
|
|
|
},
|
|
|
|
};
|
2019-12-22 02:40:42 +08:00
|
|
|
}
|