diff --git a/packages/troika-three-text/src/BatchedText.js b/packages/troika-three-text/src/BatchedText.js index 0622dbac..6fe4ff6e 100644 --- a/packages/troika-three-text/src/BatchedText.js +++ b/packages/troika-three-text/src/BatchedText.js @@ -66,9 +66,6 @@ export class BatchedText extends Text { this._onMemberSynced = (e) => { this._members.get(e.target).dirty = true; }; - this._onMemberRemoved = (e) => { - this.removeText(e.target); - }; } /** @@ -86,6 +83,20 @@ export class BatchedText extends Text { return this; } + /** + * @override + */ + remove (...objects) { + for (let i = 0; i < objects.length; i++) { + if (objects[i] instanceof Text) { + this.removeText(objects[i]); + } else { + super.remove(objects[i]); + } + } + return this; + } + /** * @param {Text} text */ @@ -96,7 +107,6 @@ export class BatchedText extends Text { glyphCount: -1, dirty: true }); - text.addEventListener("removed", this._onMemberRemoved); text.addEventListener("synccomplete", this._onMemberSynced); } } @@ -105,7 +115,6 @@ export class BatchedText extends Text { * @param {Text} text */ removeText (text) { - text.removeEventListener("removed", this._onMemberRemoved); text.removeEventListener("synccomplete", this._onMemberSynced); this._members.delete(text); }