Skip to content

Commit

Permalink
fix(troika-three-text): prevent copy() from sharing geometry between …
Browse files Browse the repository at this point in the history
…instances

Mesh.copy copies a reference to the geometry, which is never what we
want for Text because each instance has its own specific attributes.
Sharing those geometry attributes can result in very weird bugs.
  • Loading branch information
lojjic committed Jan 29, 2021
1 parent a2d631f commit 8c3ba2d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/troika-three-text/src/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,11 @@ const Text = /*#__PURE__*/(() => {
}

copy(source) {
// Prevent copying the geometry reference so we don't end up sharing attributes between instances
const geom = this.geometry
super.copy(source)
this.geometry = geom

COPYABLE_PROPS.forEach(prop => {
this[prop] = source[prop]
})
Expand Down

0 comments on commit 8c3ba2d

Please sign in to comment.