Skip to content

Commit

Permalink
Ensure correct recursive copy of the mirror node
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Mar 14, 2022
1 parent f9b4e1c commit 115f9e2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/editor/nodes/MirrorNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export default class MirrorNode extends EditorNodeMixin(Mirror) {

constructor(editor) {
super(editor);

this.color = "#7f7f7f";
}

copy(source, recursive = true) {
super.copy(source, recursive);

this.color = source.color;

return this;
}

Expand Down
18 changes: 16 additions & 2 deletions src/editor/objects/Mirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,22 @@ export default class Mirror extends Object3D {
this.mesh.material.uniforms.color.value = new Color(value);
}

copy(source) {
super.copy(source, false);
copy(source, recursive = true) {
if (recursive) {
this.remove(this.mesh);
}

super.copy(source, recursive);

if (recursive) {
const _meshIndex = source.children.indexOf(source.mesh);

if (_meshIndex !== -1) {
this.mesh = this.children[_meshIndex];
}
}

this.color = source.color;

return this;
}
Expand Down
Binary file modified test/integration/snapshots/Editor.test.js.snap
Binary file not shown.

0 comments on commit 115f9e2

Please sign in to comment.