-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aee65ae
commit 017e92a
Showing
8 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
src/Components/Core/Presentation/Babylon/StoryNPC/IStoryNPCBuilder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import IAsyncPresentationBuilder from "../../PresentationBuilder/IAsyncPresentationBuilder"; | ||
|
||
export default interface IStoryNPCBuilder extends IAsyncPresentationBuilder {} |
1 change: 1 addition & 0 deletions
1
src/Components/Core/Presentation/Babylon/StoryNPC/IStoryNPCController.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default interface IStoryNPCController {} |
1 change: 1 addition & 0 deletions
1
src/Components/Core/Presentation/Babylon/StoryNPC/IStoryNPCPresenter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default interface IStoryNPCPresenter {} |
46 changes: 46 additions & 0 deletions
46
src/Components/Core/Presentation/Babylon/StoryNPC/StoryNPCBuilder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { injectable } from "inversify"; | ||
import StoryNPCController from "./StoryNPCController"; | ||
import StoryNPCPresenter from "./StoryNPCPresenter"; | ||
import IStoryNPCController from "./IStoryNPCController"; | ||
import IStoryNPCPresenter from "./IStoryNPCPresenter"; | ||
import StoryNPCViewModel from "./StoryNPCViewModel"; | ||
import StoryNPCView from "./StoryNPCView"; | ||
import AsyncPresentationBuilder from "../../PresentationBuilder/AsyncPresentationBuilder"; | ||
import { LearningElementModel } from "src/Components/Core/Domain/LearningElementModels/LearningElementModelTypes"; | ||
|
||
/* | ||
This Template Provides the whole scaffolding for a React Component. | ||
Copy below lines in the DI Container and its Types | ||
bind<IPresentationBuilder>(BUILDER_TYPES.IStoryNPCBuilder).to(StoryNPCBuilder); | ||
IStoryNPCBuilder: Symbol("IStoryNPCBuilder"), | ||
director.Builder = CoreDIContainer.get<IPresentationBuilder>( | ||
BUILDER_TYPES.IStoryNPCBuilder | ||
); | ||
director.build(); | ||
*/ | ||
|
||
@injectable() | ||
export default class StoryNPCBuilder extends AsyncPresentationBuilder< | ||
StoryNPCViewModel, | ||
IStoryNPCController, | ||
StoryNPCView, | ||
IStoryNPCPresenter | ||
> { | ||
constructor() { | ||
super( | ||
StoryNPCViewModel, | ||
StoryNPCController, | ||
StoryNPCView, | ||
StoryNPCPresenter | ||
); | ||
} | ||
|
||
public modelType: LearningElementModel; | ||
|
||
public buildViewModel(): void { | ||
super.buildViewModel(); | ||
this.viewModel!.modelType = this.modelType; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/Components/Core/Presentation/Babylon/StoryNPC/StoryNPCController.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import IStoryNPCController from "./IStoryNPCController"; | ||
|
||
export default class StoryNPCController implements IStoryNPCController {} |
6 changes: 6 additions & 0 deletions
6
src/Components/Core/Presentation/Babylon/StoryNPC/StoryNPCPresenter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import IStoryNPCPresenter from "./IStoryNPCPresenter"; | ||
import StoryNPCViewModel from "./StoryNPCViewModel"; | ||
|
||
export default class StoryNPCPresenter implements IStoryNPCPresenter { | ||
constructor(private viewModel: StoryNPCViewModel) {} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/Components/Core/Presentation/Babylon/StoryNPC/StoryNPCView.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import LearningElementModelLookup from "src/Components/Core/Domain/LearningElementModels/LearningElementModelLookup"; | ||
import IStoryNPCController from "./IStoryNPCController"; | ||
import StoryNPCViewModel from "./StoryNPCViewModel"; | ||
import IScenePresenter from "../SceneManagement/IScenePresenter"; | ||
import CoreDIContainer from "~DependencyInjection/CoreDIContainer"; | ||
import SCENE_TYPES, { | ||
ScenePresenterFactory, | ||
} from "~DependencyInjection/Scenes/SCENE_TYPES"; | ||
import LearningSpaceSceneDefinition from "../SceneManagement/Scenes/LearningSpaceSceneDefinition"; | ||
import { Mesh } from "@babylonjs/core"; | ||
|
||
import iconLink from "../../../../../Assets/3dModels/sharedModels/l-icons-h5p-1.glb"; | ||
|
||
export default class StoryNPCView { | ||
private scenePresenter: IScenePresenter; | ||
constructor( | ||
private viewModel: StoryNPCViewModel, | ||
private controller: IStoryNPCController | ||
) { | ||
let scenePresenterFactory = CoreDIContainer.get<ScenePresenterFactory>( | ||
SCENE_TYPES.ScenePresenterFactory | ||
); | ||
this.scenePresenter = scenePresenterFactory(LearningSpaceSceneDefinition); | ||
} | ||
|
||
public async setupStoryNPC(): Promise<void> { | ||
await Promise.all([this.loadElementModel(), this.loadIconModel()]); | ||
} | ||
|
||
private async loadElementModel(): Promise<void> { | ||
let modelLink; | ||
modelLink = LearningElementModelLookup[this.viewModel.modelType]; | ||
|
||
this.viewModel.modelMeshes = (await this.scenePresenter.loadModel( | ||
modelLink, | ||
true | ||
)) as Mesh[]; | ||
} | ||
|
||
private async loadIconModel(): Promise<void> { | ||
this.viewModel.iconMeshes = (await this.scenePresenter.loadModel( | ||
iconLink | ||
)) as Mesh[]; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/Components/Core/Presentation/Babylon/StoryNPC/StoryNPCViewModel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Mesh } from "@babylonjs/core"; | ||
import { LearningElementModel } from "src/Components/Core/Domain/LearningElementModels/LearningElementModelTypes"; | ||
|
||
export default class StoryNPCViewModel { | ||
modelType: LearningElementModel; | ||
modelMeshes: Mesh[]; | ||
iconMeshes: Mesh[]; | ||
} |