Don't switch layer on addSeg
This commit is contained in:
parent
3392ab87d2
commit
cc2fac6d4b
@ -24,8 +24,7 @@ function Listener (dotgrid) {
|
|||||||
function operate (data) {
|
function operate (data) {
|
||||||
if (!data) { return }
|
if (!data) { return }
|
||||||
if (!dotgrid.tool.layers[data.layer]) { return }
|
if (!dotgrid.tool.layers[data.layer]) { return }
|
||||||
dotgrid.tool.index = data.layer
|
dotgrid.tool.addSegment(data.type, [data.from, data.to], data.layer)
|
||||||
dotgrid.tool.addSegment(data.type, [data.from, data.to])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw () {
|
function draw () {
|
||||||
|
@ -153,12 +153,12 @@ function Tool (dotgrid) {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addSegment = function (type, vertices) {
|
this.addSegment = function (type, vertices, index = this.index) {
|
||||||
let append_target = this.canAppend({ type: type, vertices: vertices })
|
let append_target = this.canAppend({ type: type, vertices: vertices })
|
||||||
if (append_target) {
|
if (append_target) {
|
||||||
this.layer()[append_target].vertices = this.layer()[append_target].vertices.concat(vertices)
|
this.layer(index)[append_target].vertices = this.layer(index)[append_target].vertices.concat(vertices)
|
||||||
} else {
|
} else {
|
||||||
this.layer().push({ type: type, vertices: vertices })
|
this.layer(index).push({ type: type, vertices: vertices })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,11 +346,11 @@ function Tool (dotgrid) {
|
|||||||
|
|
||||||
// Layers
|
// Layers
|
||||||
|
|
||||||
this.layer = function () {
|
this.layer = function (index = this.index) {
|
||||||
if (!this.layers[this.index]) {
|
if (!this.layers[index]) {
|
||||||
this.layers[this.index] = []
|
this.layers[index] = []
|
||||||
}
|
}
|
||||||
return this.layers[this.index]
|
return this.layers[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
this.selectLayer = function (id) {
|
this.selectLayer = function (id) {
|
||||||
|
Loading…
Reference in New Issue
Block a user