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

Commit

Permalink
fix(core): adjust propertyToAttach on ngtInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Apr 9, 2022
1 parent 56d437b commit 143aa5c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions libs/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export * from './lib/di/audio';
export * from './lib/di/camera';
export * from './lib/di/geometry';
export * from './lib/di/material';
export * from './lib/di/curve';

export * from './lib/pipes/math';
export * from './lib/pipes/vector';
Expand Down
24 changes: 13 additions & 11 deletions libs/core/src/lib/abstracts/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,19 @@ export abstract class NgtInstance<
tap(([, attach]) => {
if (!this.parentInstanceFactory) return;

const propertyToAttach = [];
if (Array.isArray(attach)) {
if (attach.length === 0) {
if (this.instance) {
if (isMaterial(this.instance)) {
propertyToAttach.push('material');
} else if (isGeometry(this.instance)) {
propertyToAttach.push('geometry');
}
}
}
}

if (!this.shouldAttach) {
this.shouldAttach =
typeof attach === 'function' || attach.length > 0;
Expand All @@ -195,17 +208,6 @@ export abstract class NgtInstance<
this.__ngt__.previousAttach = attachCleanUp;
}
} else {
const propertyToAttach = [...attach];
if (propertyToAttach.length === 0) {
if (this.instance) {
if (isMaterial(this.instance)) {
propertyToAttach.push('material');
} else if (isGeometry(this.instance)) {
propertyToAttach.push('geometry');
}
}
}

if (propertyToAttach.length === 0) {
// TODO: warn users about invalid attach params
return;
Expand Down

0 comments on commit 143aa5c

Please sign in to comment.