From fd8787f334c068676b306c910892e3d531051a07 Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Fri, 2 Jun 2023 16:24:28 +0200 Subject: [PATCH] Dispose created geometry on remove and put back the original one --- index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.js b/index.js index 2c363a8..a1290b9 100755 --- a/index.js +++ b/index.js @@ -93,6 +93,7 @@ module.exports = { uvAttribute.needsUpdate = true + this.originalGeometry = object3D.geometry; object3D.geometry = geometry } @@ -107,6 +108,14 @@ module.exports = { }, + remove() { + var object3D = this.el.object3D.children[0]; + object3D.geometry.dispose(); + if (this.originalGeometry) { + object3D.geometry = this.originalGeometry; + } + }, + // On element update, put in the right layer, 0:both, 1:left, 2:right (spheres or not) update: function(oldData){