From e92a62b45b773095ac2b275f0004301d1bf39c87 Mon Sep 17 00:00:00 2001 From: Kevin LEVRON Date: Thu, 11 Mar 2021 23:58:05 +0100 Subject: [PATCH] few adjustments --- src/core/Object3D.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 88c0f19..1355204 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -13,15 +13,7 @@ export default { // can't use setup because it will not be used in sub components // setup() {}, unmounted() { - // 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; - } + if (this._parent) this._parent.remove(this.o3d); }, methods: { initObject3D(o3d) { @@ -31,19 +23,20 @@ export default { bindProp(this, 'rotation', this.o3d); bindProp(this, 'scale', this.o3d); - // fix lookat.x + // TODO : fix lookat.x 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 ancestors until we find something we can add to let parent = this.$parent; while (parent) { if (parent.add) { parent.add(this.o3d); + this._parent = parent; break; } parent = parent.$parent; } + if (!this._parent) console.error('Missing parent (Scene, Group...)'); }, add(o) { this.o3d.add(o); }, remove(o) { this.o3d.remove(o); },