deep clone + args, rework/cleanup ui binding, preserve groups on poly re-nest
This commit is contained in:
parent
15a0131c6b
commit
18b6b8567a
8 changed files with 238 additions and 222 deletions
|
|
@ -913,32 +913,33 @@ class Polygon {
|
|||
* @param {Boolean} deep
|
||||
* @returns {Polygon}
|
||||
*/
|
||||
clone(deep) {
|
||||
clone(deep, fields) {
|
||||
let np = newPolygon().copyZ(this.getZ()),
|
||||
ln = this.length,
|
||||
i = 0;
|
||||
|
||||
while (i < ln) np.push(this.points[i++]);
|
||||
|
||||
if (this.fillang) np.fillang = this.fillang;
|
||||
fields && fields.forEach(field => np[field] = this[field]);
|
||||
this.fillang && (np.fillang = this.fillang);
|
||||
np.depth = this.depth;
|
||||
np.open = this.open;
|
||||
|
||||
if (deep && this.inner) {
|
||||
np.inner = this.inner.clone();
|
||||
np.inner = this.inner.clone(false, fields);
|
||||
}
|
||||
|
||||
return np;
|
||||
}
|
||||
|
||||
// special shallow for-render-or-read-only cloning
|
||||
cloneZ(z, stop) {
|
||||
cloneZ(z, deep = true) {
|
||||
let p = newPolygon();
|
||||
p.z = z;
|
||||
p.open = this.open;
|
||||
p.points = this.points;
|
||||
if (this.inner) {
|
||||
p.inner = this.inner.map(p => p.cloneZ(z, true));
|
||||
if (deep && this.inner) {
|
||||
p.inner = this.inner.map(p => p.cloneZ(z, false));
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue