Skip to content

Commit 66a98e3

Browse files
committed
fix: prevent a THREE child is attached to a parent when it is already attached
1 parent f2a77d1 commit 66a98e3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

libs/angular-three/src/lib/renderer/renderer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ export class NgtRenderer implements Renderer2 {
182182
parent.__ngt_renderer__[NgtRendererClassId.type] === 'three' &&
183183
newChild.__ngt_renderer__[NgtRendererClassId.type] === 'three'
184184
) {
185+
// if child already attached to a parent, skip
186+
if (getLocalState(newChild).parent) return;
187+
// attach THREE child
185188
attachThreeChild(parent, newChild);
186189
// here, we handle the special case of if the parent has a compoundParent, which means this child is part of a compound parent template
187190
if (!newChild.__ngt_renderer__[NgtRendererClassId.compound]) return;

0 commit comments

Comments
 (0)