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";
|
2019-12-22 02:40:42 +08:00
|
|
|
|
2019-12-22 07:43:27 +08:00
|
|
|
export function initialize_viewer(
|
|
|
|
http_client: HttpClient,
|
|
|
|
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,
|
2019-12-22 02:40:42 +08:00
|
|
|
async () => {
|
|
|
|
const { Model3DStore } = await import("./stores/Model3DStore");
|
|
|
|
const { Model3DView } = await import("./gui/model_3d/Model3DView");
|
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));
|
|
|
|
const store = new Model3DStore(asset_loader);
|
2019-12-25 07:17:02 +08:00
|
|
|
|
|
|
|
if (disposer.disposed) {
|
|
|
|
store.dispose();
|
|
|
|
} else {
|
|
|
|
disposer.add(store);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Model3DView(gui_store, store, create_three_renderer());
|
2019-12-22 02:40:42 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
async () => {
|
|
|
|
const { TextureStore } = await import("./stores/TextureStore");
|
|
|
|
const { TextureView } = await import("./gui/TextureView");
|
2019-12-25 07:17:02 +08:00
|
|
|
const store = new TextureStore();
|
|
|
|
|
|
|
|
if (disposer.disposed) {
|
|
|
|
store.dispose();
|
|
|
|
} else {
|
|
|
|
disposer.add(store);
|
|
|
|
}
|
|
|
|
|
2020-01-05 08:07:35 +08:00
|
|
|
return new TextureView(store, 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
|
|
|
}
|