Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
Showing 19 changed files with 613 additions and 704 deletions.
279 changes: 207 additions & 72 deletions libs/core/src/lib/abstracts/instance.ts

Large diffs are not rendered by default.

35 changes: 10 additions & 25 deletions libs/core/src/lib/abstracts/material-geometry.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ export interface NgtMaterialGeometryState<
geometry: THREE.BufferGeometry;
morphTargetInfluences?: number[];
morphTargetDictionary?: Record<string, number>;
[propKey: string]: any;
}

@Directive()
@@ -41,55 +40,41 @@ export abstract class NgtMaterialGeometry<
abstract get objectType(): AnyConstructor<TMaterialGeometryObject>;

protected override objectInitFn(): TMaterialGeometryObject {
const props = this.get();
const state = this.get();

// this is the additional arguments to pass into the object constructor
// eg: InstancedMesh has "count" -> objectArgs = [count]
const objectArgs = this.argsKeys.reduce((args, argKey) => {
args.push(props[argKey]);
args.push(state[argKey]);
return args;
}, [] as unknown[]);

const object = new this.objectType(
props.geometry,
props.material,
state.geometry,
state.material,
...objectArgs
);

if (props.morphTargetDictionary && 'morphTargetDictionary' in object) {
if (state.morphTargetDictionary && 'morphTargetDictionary' in object) {
(object as unknown as UnknownRecord)['morphTargetDictionary'] =
props.morphTargetDictionary;
state.morphTargetDictionary;
}

if (props.morphTargetInfluences && 'morphTargetInfluences' in object) {
if (state.morphTargetInfluences && 'morphTargetInfluences' in object) {
(object as unknown as UnknownRecord)['morphTargetInfluences'] =
props.morphTargetInfluences;
}

if (this.postInit) {
this.postInit();
state.morphTargetInfluences;
}

return object;
}

override ngOnInit() {
this.init();
super.ngOnInit();
}

/**
* to run after object has been initialized
*/
// eslint-disable-next-line @typescript-eslint/no-empty-function
protected postInit(): void {}

protected get argsKeys(): string[] {
return [];
}

protected override get subInputs(): Record<string, boolean> {
protected override get optionFields(): Record<string, boolean> {
return {
...super.optionFields,
material: true,
geometry: true,
morphTargetInfluences: true,
Loading

0 comments on commit 9763a8b

Please sign in to comment.