This repository has been archived by the owner on Feb 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): refactor how Geometry/Material works
- Before Geometry and Material are added to the parent Object3d (Mesh) by Content Querying for `NgtMaterial` and `NgtGeometry` on `ContentMaterialController` and `ContentGeometryController` (respectively) - This causes a problem where the following wouldn't work: ```html <ngt-mesh> <ngt-box-geometry></ngt-box-geometry> <some-abstract-material-component></some-abstract-material-component> </ngt-mesh> ``` - `some-abstract-material-component` is a wrapper around a Material. Think of making a Material a component so that it can be managed on its own (maybe it has `texture` that loads from external sources etc...). Content Querying cannot query for the Material that `some-abstract-material-component` wraps. - This has been changed to using DI to try to inject the parent Mesh into the Geometry and Material instead. The Geometry and Material then assign themselves on the Mesh. This requires that the Mesh needs to be provided by: - All Meshes - All Soba shapes - Any Material/Geometry objects
- Loading branch information
Showing
13 changed files
with
129 additions
and
93 deletions.
There are no files selected for viewing
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
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
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
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
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
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,30 @@ | ||
import { InjectionToken, Optional, Provider, SkipSelf } from '@angular/core'; | ||
import * as THREE from 'three'; | ||
import { | ||
NGT_OBJECT_WATCHED_CONTROLLER, | ||
NgtObject3dController, | ||
} from '../controllers/object-3d.controller'; | ||
import { AnyFunction } from '../models'; | ||
import { NgtSobaExtender } from '../three/extender'; | ||
|
||
export const NGT_OBJECT_3D = new InjectionToken<AnyFunction<THREE.Object3D>>( | ||
'THREE_OBJECT_3D' | ||
); | ||
|
||
export const NGT_OBJECT_3D_PROVIDER: Provider = { | ||
provide: NGT_OBJECT_3D, | ||
useFactory: ( | ||
sobaExtender: NgtSobaExtender<THREE.Object3D>, | ||
objectController: NgtObject3dController | ||
) => { | ||
return () => { | ||
if (sobaExtender) return sobaExtender.object; | ||
if (objectController) return objectController.object3d; | ||
return null; | ||
}; | ||
}, | ||
deps: [ | ||
[new Optional(), new SkipSelf(), NgtSobaExtender], | ||
[new Optional(), new SkipSelf(), NGT_OBJECT_WATCHED_CONTROLLER], | ||
], | ||
}; |
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
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
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
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
Oops, something went wrong.