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

Commit

Permalink
fix(core): add reconstruct flag so the consumers and other sub classe…
Browse files Browse the repository at this point in the history
…s can determine whether to reconstruct an object
  • Loading branch information
nartc committed Apr 8, 2022
1 parent a1f7eda commit 3aeebb1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 14 additions & 2 deletions libs/core/src/lib/abstracts/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ export abstract class NgtObject<
this.set({ appendTo } as Partial<TObjectState>);
}

private _reconstruct = false;
get reconstruct(): boolean {
return this._reconstruct;
}
@Input() set reconstruct(reconstruct: BooleanInput) {
this._reconstruct = coerceBooleanProperty(reconstruct);
}

// events
@Output() click = new EventEmitter<NgtEvent<MouseEvent>>();
@Output() contextmenu = new EventEmitter<NgtEvent<MouseEvent>>();
Expand Down Expand Up @@ -249,7 +257,7 @@ export abstract class NgtObject<
return this.get((s) => s.object3d) as TObject;
}

init() {
init(reconstruct = false) {
this.zone.runOutsideAngular(() => {
if (this.initSubscription) {
this.initSubscription.unsubscribe();
Expand All @@ -258,7 +266,11 @@ export abstract class NgtObject<
this.initSubscription = this.onCanvasReady(
this.store.ready$,
() => {
if (this.object3d) {
if (reconstruct !== this.reconstruct) {
reconstruct = this.reconstruct;
}

if (this.object3d && reconstruct) {
this.switch();
} else {
const object = prepare(
Expand Down
1 change: 0 additions & 1 deletion libs/core/src/lib/three/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ export abstract class NgtCommonAudio<

protected override get subInputs(): Record<string, boolean> {
return {
listener: false,
autoplay: true,
buffer: false,
detune: false,
Expand Down

0 comments on commit 3aeebb1

Please sign in to comment.