fix patterning, add duplication preferences
This commit is contained in:
parent
ed5186fdbb
commit
6df554bf72
5 changed files with 49 additions and 29 deletions
|
|
@ -310,8 +310,9 @@ const pattern = {
|
||||||
for (let i=1; i<count; i++) {
|
for (let i=1; i<count; i++) {
|
||||||
let clone = await model.duplicate();
|
let clone = await model.duplicate();
|
||||||
let [x, y] = base.util.rotate(pos.x - cx, pos.y - cy, stepr * i);
|
let [x, y] = base.util.rotate(pos.x - cx, pos.y - cy, stepr * i);
|
||||||
|
clone.group.centerModels().position(0,0,0);
|
||||||
clone.group.rotate(0, 0, stepr * i);
|
clone.group.rotate(0, 0, stepr * i);
|
||||||
clone.group.position(x + cx, y + cy, pos.z);
|
clone.group.move(x + cx, y + cy, pos.z);
|
||||||
modnu.push(clone);
|
modnu.push(clone);
|
||||||
}
|
}
|
||||||
await api.tool.regroup(modnu);
|
await api.tool.regroup(modnu);
|
||||||
|
|
@ -351,7 +352,7 @@ const pattern = {
|
||||||
for (let j=0; j<y; j++) {
|
for (let j=0; j<y; j++) {
|
||||||
if (i === 0 && j === 0) continue;
|
if (i === 0 && j === 0) continue;
|
||||||
let clone = await model.duplicate();
|
let clone = await model.duplicate();
|
||||||
clone.group.position(i * xs + pos.x, -j * ys + pos.y, pos.z);
|
clone.group.centerModels().position(i * xs + pos.x, -j * ys + pos.y, pos.z);
|
||||||
modnu.push(clone);
|
modnu.push(clone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -402,7 +403,7 @@ const group = {
|
||||||
add(group) {
|
add(group) {
|
||||||
groups.addOnce(group);
|
groups.addOnce(group);
|
||||||
space.world.add(group.object);
|
space.world.add(group.object);
|
||||||
api.selection.update();
|
util.defer(selection.update);
|
||||||
space.update();
|
space.update();
|
||||||
return group;
|
return group;
|
||||||
},
|
},
|
||||||
|
|
@ -426,7 +427,7 @@ let sketch = {
|
||||||
add(sk) {
|
add(sk) {
|
||||||
sketches.addOnce(sk);
|
sketches.addOnce(sk);
|
||||||
space.world.add(sk.object);
|
space.world.add(sk.object);
|
||||||
api.selection.update();
|
util.defer(selection.update);
|
||||||
return sk;
|
return sk;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -900,8 +901,13 @@ const tool = {
|
||||||
},
|
},
|
||||||
|
|
||||||
duplicate() {
|
duplicate() {
|
||||||
for (let m of selection.models()) {
|
let { dup_shift, dup_sel } = api.prefs.map.space;
|
||||||
m.duplicate();
|
let models = selection.models();
|
||||||
|
if (dup_sel) {
|
||||||
|
selection.clear();
|
||||||
|
}
|
||||||
|
for (let m of models) {
|
||||||
|
m.duplicate({ select: dup_sel, shift: dup_shift });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -931,7 +937,7 @@ const tool = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
model.rename( $('tempedit').value.trim() );
|
model.rename( $('tempedit').value.trim() );
|
||||||
selection.update();
|
util.defer(selection.update);
|
||||||
api.modal.hide();
|
api.modal.hide();
|
||||||
};
|
};
|
||||||
let { tempedit } = api.modal.show(`rename ${type}`, h.div({ class: "rename"}, [
|
let { tempedit } = api.modal.show(`rename ${type}`, h.div({ class: "rename"}, [
|
||||||
|
|
@ -953,8 +959,7 @@ const tool = {
|
||||||
return Promise.all(models.map(m => m.ungroup())).then(() => {
|
return Promise.all(models.map(m => m.ungroup())).then(() => {
|
||||||
return mesh.api.group.new(models)
|
return mesh.api.group.new(models)
|
||||||
.centerModels()
|
.centerModels()
|
||||||
.position(mid.x, mid.y, mid.z)
|
.position(mid.x, mid.y, mid.z);;
|
||||||
.setSelected();
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -972,7 +977,7 @@ const tool = {
|
||||||
mesh: area.toFloat32()
|
mesh: area.toFloat32()
|
||||||
})).map( nm => nm.applyMatrix4(mcore.clone().multiply(m.mesh.matrixWorld)) );
|
})).map( nm => nm.applyMatrix4(mcore.clone().multiply(m.mesh.matrixWorld)) );
|
||||||
if (nm.length) {
|
if (nm.length) {
|
||||||
mesh.api.group.new(nm, undefined, "patch").setSelected();
|
mesh.api.group.new(nm, undefined, "patch");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
promises.push(p);
|
promises.push(p);
|
||||||
|
|
@ -994,7 +999,7 @@ const tool = {
|
||||||
file: m.file,
|
file: m.file,
|
||||||
mesh: vert.toFloat32()
|
mesh: vert.toFloat32()
|
||||||
})).map( nm => nm.applyMatrix4(mcore.clone().multiply(m.mesh.matrixWorld)) );
|
})).map( nm => nm.applyMatrix4(mcore.clone().multiply(m.mesh.matrixWorld)) );
|
||||||
mesh.api.group.new(bodies, undefined, "isolate").setSelected();
|
mesh.api.group.new(bodies, undefined, "isolate");
|
||||||
});
|
});
|
||||||
promises.push(p);
|
promises.push(p);
|
||||||
}
|
}
|
||||||
|
|
@ -1050,7 +1055,7 @@ const tool = {
|
||||||
log('repairing mesh(es)').pin();
|
log('repairing mesh(es)').pin();
|
||||||
tool.heal(models, { merge: true }).then(() => {
|
tool.heal(models, { merge: true }).then(() => {
|
||||||
log('repair commplete').unpin();
|
log('repair commplete').unpin();
|
||||||
api.selection.update();
|
util.defer(selection.update);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -1058,7 +1063,7 @@ const tool = {
|
||||||
models = fallback(models);
|
models = fallback(models);
|
||||||
tool.heal(models, { merge: false }).then(() => {
|
tool.heal(models, { merge: false }).then(() => {
|
||||||
log('cleaning complete').unpin();
|
log('cleaning complete').unpin();
|
||||||
api.selection.update();
|
util.defer(selection.update);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -1176,8 +1181,8 @@ const prefs = {
|
||||||
space: {
|
space: {
|
||||||
snap: 1,
|
snap: 1,
|
||||||
snapon: false,
|
snapon: false,
|
||||||
center: true,
|
center: false,
|
||||||
floor: true,
|
floor: false,
|
||||||
wire: false,
|
wire: false,
|
||||||
grid: true,
|
grid: true,
|
||||||
dark: false,
|
dark: false,
|
||||||
|
|
|
||||||
|
|
@ -262,11 +262,11 @@ api.settings = function() {
|
||||||
const set3 = h.div([
|
const set3 = h.div([
|
||||||
h.label({ class: "header", _: 'normal'}),
|
h.label({ class: "header", _: 'normal'}),
|
||||||
h.label('length'),
|
h.label('length'),
|
||||||
h.input({ type: "text", size: 5, value: parseFloat(normals.length),
|
h.input({ type: "text", size: 6, value: parseFloat(normals.length),
|
||||||
onchange: ev => call.set_normals_length(ev.target.value)
|
onchange: ev => call.set_normals_length(ev.target.value)
|
||||||
}),
|
}),
|
||||||
h.label('color'),
|
h.label('color'),
|
||||||
h.input({ type: "text", size: 5,
|
h.input({ type: "text", size: 6,
|
||||||
value: util.toHexRGB(dark ? normals.color_dark : normals.color_lite),
|
value: util.toHexRGB(dark ? normals.color_dark : normals.color_lite),
|
||||||
onchange: ev => call.set_normals_color(util.fromHexRGB(ev.target.value))
|
onchange: ev => call.set_normals_color(util.fromHexRGB(ev.target.value))
|
||||||
}),
|
}),
|
||||||
|
|
@ -297,7 +297,23 @@ api.settings = function() {
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
modal.show('settings', h.div({ class: "settings" }, [ set1, set2, set3, set4, set5 ] ));
|
const set6 = h.div([
|
||||||
|
h.label({ class: "header", _: 'duplicate'}),
|
||||||
|
h.label('select'),
|
||||||
|
h.input({ type: "checkbox",
|
||||||
|
onchange: ev => prefs.save( space.dup_sel = !space.dup_sel ),
|
||||||
|
[ space.dup_sel === true ? 'checked' : 'unchecked' ] : 1
|
||||||
|
}),
|
||||||
|
h.label('shift'),
|
||||||
|
h.input({ type: "checkbox",
|
||||||
|
onchange: ev => prefs.save( space.dup_shift = !space.dup_shift ),
|
||||||
|
[ space.dup_shift === true ? 'checked' : 'unchecked' ] : 1
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
modal.show('settings', h.div({ class: "settings" }, [
|
||||||
|
set1, set2, set3, set4, set5, set6
|
||||||
|
] ));
|
||||||
}
|
}
|
||||||
|
|
||||||
// create html elements
|
// create html elements
|
||||||
|
|
|
||||||
|
|
@ -154,13 +154,6 @@ mesh.group = class MeshGroup extends mesh.object {
|
||||||
model.select(...arguments);
|
model.select(...arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok, this is confusing, but necessary for now :/
|
|
||||||
// todo: obsolete?
|
|
||||||
setSelected() {
|
|
||||||
// super.select();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
return worker.model_duplicate({
|
return worker.model_duplicate({
|
||||||
matrix: this.matrix,
|
matrix: this.matrix,
|
||||||
id: this.id,
|
id: this.id,
|
||||||
opt: { mirror: opt.mirror}
|
opt: { mirror: opt.mirror }
|
||||||
}).then(data => {
|
}).then(data => {
|
||||||
if (opt.append) data = [...data, ...opt.append].toFloat32();
|
if (opt.append) data = [...data, ...opt.append].toFloat32();
|
||||||
if (opt.reload) return this.reload(data);
|
if (opt.reload) return this.reload(data);
|
||||||
|
|
@ -213,9 +213,14 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
let group = opt.group || mesh.api.group.new();
|
let group = opt.group || mesh.api.group.new();
|
||||||
group.add(model);
|
group.add(model);
|
||||||
model.wireframe(this.wireframe());
|
model.wireframe(this.wireframe());
|
||||||
model.normals(this.normals());
|
if (opt.select) {
|
||||||
if (opt.select) group.setSelected();
|
api.selection.add(model);
|
||||||
if (opt.mirror) group.move(0, 0, group.bounds.dim.z);
|
}
|
||||||
|
if (opt.mirror) {
|
||||||
|
group.move(0, 0, group.bounds.dim.z);
|
||||||
|
} else if (opt.shift) {
|
||||||
|
group.move(group.bounds.dim.x, 0, 0);
|
||||||
|
}
|
||||||
return model;
|
return model;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -445,6 +445,7 @@ button:hover {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
|
justify-self: end;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** spinner animation **/
|
/** spinner animation **/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue