From e47f6094e8f4cedda875b811d6256c5dd29b32d3 Mon Sep 17 00:00:00 2001 From: Sander Moolin Date: Thu, 11 Mar 2021 17:15:52 -0500 Subject: [PATCH] Removes successfully --- src/core/Object3D.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 5635d7d..88c0f19 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -13,7 +13,15 @@ export default { // can't use setup because it will not be used in sub components // setup() {}, unmounted() { - if (this.$parent.remove) this.$parent.remove(this.o3d); + // traverse ancestors until we find something we can remove from + let parent = this.$parent; + while (parent) { + if (parent.remove) { + parent.remove(this.o3d); + break; + } + parent = parent.$parent; + } }, methods: { initObject3D(o3d) { @@ -27,7 +35,7 @@ export default { if (this.lookAt) this.o3d.lookAt(this.lookAt.x, this.lookAt.y, this.lookAt.z); watch(() => this.lookAt, (v) => { this.o3d.lookAt(v.x, v.y, v.z); }, { deep: true }); - // traverse parents until we find something we can add to + // traverse ancestors until we find something we can add to let parent = this.$parent; while (parent) { if (parent.add) {