checkpoint
This commit is contained in:
parent
65f6c7deec
commit
4b986fa862
5 changed files with 21 additions and 26 deletions
|
|
@ -576,7 +576,7 @@ function ui_build() {
|
||||||
tool_item('bi-layers', 'Flatten', sketch.boolean.flatten),
|
tool_item('bi-layers', 'Flatten', sketch.boolean.flatten),
|
||||||
tool_item('bi-cookie', 'Even Odd', sketch.boolean.evenodd),
|
tool_item('bi-cookie', 'Even Odd', sketch.boolean.evenodd),
|
||||||
tool_item('bi-arrow-bar-up', 'Extrude', () => sketch.extrude()),
|
tool_item('bi-arrow-bar-up', 'Extrude', () => sketch.extrude()),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
// bind object chiclets
|
// bind object chiclets
|
||||||
bind(objecttools, div([
|
bind(objecttools, div([
|
||||||
|
|
@ -588,13 +588,13 @@ function ui_build() {
|
||||||
tool_item('bi-subtract', 'Subtract', tool.subtract),
|
tool_item('bi-subtract', 'Subtract', tool.subtract),
|
||||||
tool_item('bi-intersect', 'Intersect', tool.intersect),
|
tool_item('bi-intersect', 'Intersect', tool.intersect),
|
||||||
tool_item('bi-exclude', 'Difference', tool.difference),
|
tool_item('bi-exclude', 'Difference', tool.difference),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
// create slid in/out logging window
|
// create slid in/out logging window
|
||||||
bind(logger, [ div({ id: 'logtext' }) ]);
|
bind(logger, [ div({ id: 'logtext' }) ]);
|
||||||
|
|
||||||
// for group/model/box/area/mesh dashboard grids
|
// for group/model/box/area/mesh dashboard grids
|
||||||
function grid(v1, v2, side = [ "pos", "rot"], top = [ "X", "Y", "Z" ], root) {
|
function grid3(v1, v2, side = [ "pos", "rot"], top = [ "X", "Y", "Z" ], root) {
|
||||||
let v = 'val', l = 'lbl';
|
let v = 'val', l = 'lbl';
|
||||||
let [ X, Y, Z ] = top;
|
let [ X, Y, Z ] = top;
|
||||||
let [ pos, rot ] = side;
|
let [ pos, rot ] = side;
|
||||||
|
|
@ -811,7 +811,7 @@ function ui_build() {
|
||||||
center: sketch.center
|
center: sketch.center
|
||||||
};
|
};
|
||||||
let sel = sketch.selection.mesh_items();
|
let sel = sketch.selection.mesh_items();
|
||||||
let sk_vars = sblock('sketch', sketch.file || sketch.id, grid(
|
let sk_vars = sblock('sketch', sketch.file || sketch.id, grid3(
|
||||||
util.extract(bounds.center, map),
|
util.extract(bounds.center, map),
|
||||||
util.extract(bounds.size, map),
|
util.extract(bounds.size, map),
|
||||||
[ "center", "scale" ], und, 'sketch'
|
[ "center", "scale" ], und, 'sketch'
|
||||||
|
|
@ -911,7 +911,7 @@ function ui_build() {
|
||||||
let g_pos = util.average(s_grp.map(g => g.object.position));
|
let g_pos = util.average(s_grp.map(g => g.object.position));
|
||||||
let g_rot = util.average(s_grp.map(g => g.object.rotation));
|
let g_rot = util.average(s_grp.map(g => g.object.rotation));
|
||||||
let g_id = s_grp.map(g => g.id).join(' ');
|
let g_id = s_grp.map(g => g.id).join(' ');
|
||||||
let h_grp = sblock('orient', g_id, grid(
|
let h_grp = sblock('orient', g_id, grid3(
|
||||||
util.extract(g_pos, map),
|
util.extract(g_pos, map),
|
||||||
util.extract(g_rot).map(r => (r * rad).round(2).toFixed(map.fixed)),
|
util.extract(g_rot).map(r => (r * rad).round(2).toFixed(map.fixed)),
|
||||||
und, und, 'group'
|
und, und, 'group'
|
||||||
|
|
@ -922,7 +922,7 @@ function ui_build() {
|
||||||
let m_id = s_mdl.map(m => m.id).join(' ');
|
let m_id = s_mdl.map(m => m.id).join(' ');
|
||||||
|
|
||||||
let bounds = util.bounds(s_mdl);
|
let bounds = util.bounds(s_mdl);
|
||||||
let h_ara = sblock('span', m_id, grid(
|
let h_ara = sblock('span', m_id, grid3(
|
||||||
util.extract(bounds.center, map),
|
util.extract(bounds.center, map),
|
||||||
util.extract(bounds.size, map),
|
util.extract(bounds.size, map),
|
||||||
[ "center", "size" ], und, 'span'
|
[ "center", "size" ], und, 'span'
|
||||||
|
|
@ -972,16 +972,13 @@ function ui_build() {
|
||||||
e.classList.add('editable');
|
e.classList.add('editable');
|
||||||
});
|
});
|
||||||
group_val_X_rot.onclick = field_edit('x rotation', (group, val) => {
|
group_val_X_rot.onclick = field_edit('x rotation', (group, val) => {
|
||||||
let r = group.rotation();
|
group.rotate(val,0,0);
|
||||||
group.rotation(val/rad, r.y, r.z);
|
|
||||||
});
|
});
|
||||||
group_val_Y_rot.onclick = field_edit('y rotation', (group, val) => {
|
group_val_Y_rot.onclick = field_edit('y rotation', (group, val) => {
|
||||||
let r = group.rotation();
|
group.rotate(0,val,0);
|
||||||
group.rotation(r.x, val/rad, r.z);
|
|
||||||
});
|
});
|
||||||
group_val_Z_rot.onclick = field_edit('z rotation', (group, val) => {
|
group_val_Z_rot.onclick = field_edit('z rotation', (group, val) => {
|
||||||
let r = group.rotation();
|
group.rotate(0,0,val);
|
||||||
group.rotation(r.x, r.y, val/rad);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// bind position editable fields
|
// bind position editable fields
|
||||||
|
|
|
||||||
|
|
@ -109,17 +109,11 @@ mesh.group = class MeshGroup extends mesh.object {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
xrotate(x = 0, y = 0, z = 0) {
|
rotate(x = 0, y = 0, z = 0) {
|
||||||
console.log('group rotate', ...arguments);
|
console.log('group rotate', ...arguments);
|
||||||
// super.rotate(...arguments);
|
|
||||||
for (let model of this.models) {
|
for (let model of this.models) {
|
||||||
worker.model_rotate({ id: model.id, x, y, z });
|
model.rotate(...arguments);
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
|
||||||
for (let model of this.models) {
|
|
||||||
model.attributes.position.needsUpdate = true;
|
|
||||||
}
|
|
||||||
}, 250);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scale(x = 1, y = 1, z = 1) {
|
scale(x = 1, y = 1, z = 1) {
|
||||||
|
|
|
||||||
|
|
@ -168,11 +168,14 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
|
|
||||||
rotate(x = 0, y = 0, z = 0) {
|
rotate(x = 0, y = 0, z = 0) {
|
||||||
console.log('model rotate', ...arguments);
|
console.log('model rotate', ...arguments);
|
||||||
super.rotate(...arguments);
|
worker.model_rotate({ id: this.id, x, y, z }).then(() => {
|
||||||
|
this.attributes.position.needsUpdate = true;
|
||||||
|
moto.space.update();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// override and translate mesh
|
// override and translate mesh
|
||||||
move(x = 0, y = 0, z = 0) {
|
xmove(x = 0, y = 0, z = 0) {
|
||||||
let attr = this.attributes;
|
let attr = this.attributes;
|
||||||
let arr = attr.position.array;
|
let arr = attr.position.array;
|
||||||
for (let i=0, l=arr.length; i<l; ) {
|
for (let i=0, l=arr.length; i<l; ) {
|
||||||
|
|
@ -185,7 +188,7 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
}
|
}
|
||||||
|
|
||||||
// override and translate mesh
|
// override and translate mesh
|
||||||
scale(x = 1, y = 1, z = 1) {
|
xscale(x = 1, y = 1, z = 1) {
|
||||||
let attr = this.attributes;
|
let attr = this.attributes;
|
||||||
let arr = attr.position.array;
|
let arr = attr.position.array;
|
||||||
for (let i=0, l=arr.length; i<l; ) {
|
for (let i=0, l=arr.length; i<l; ) {
|
||||||
|
|
@ -282,7 +285,7 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
reload(vertices) {
|
reload(vertices) {
|
||||||
let local = mesh.util.toLocal32(vertices);
|
let local = mesh.util.toLocal32(vertices);
|
||||||
let shared = mesh.util.toSharedF32(vertices);
|
let shared = mesh.util.toSharedF32(vertices);
|
||||||
console.log('reload', { vertices, local, shared });
|
console.trace('reload', { vertices, local, shared });
|
||||||
let was = this.wireframe(false);
|
let was = this.wireframe(false);
|
||||||
let geo = this.mesh.geometry;
|
let geo = this.mesh.geometry;
|
||||||
geo.setAttribute('position', new BufferAttribute(shared, 3));
|
geo.setAttribute('position', new BufferAttribute(shared, 3));
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,8 @@ mesh.object = class MeshObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
rotate(x = 0, y = 0, z = 0) {
|
rotate(x = 0, y = 0, z = 0) {
|
||||||
console.log('rotate', ...arguments);
|
throw "rotate() requires implementation";
|
||||||
|
console.log('object rotate', ...arguments);
|
||||||
if (x) this.object.rotateOnWorldAxis(new Vector3(1,0,0), x);
|
if (x) this.object.rotateOnWorldAxis(new Vector3(1,0,0), x);
|
||||||
if (y) this.object.rotateOnWorldAxis(new Vector3(0,1,0), y);
|
if (y) this.object.rotateOnWorldAxis(new Vector3(0,1,0), y);
|
||||||
if (z) this.object.rotateOnWorldAxis(new Vector3(0,0,1), z);
|
if (z) this.object.rotateOnWorldAxis(new Vector3(0,0,1), z);
|
||||||
|
|
@ -137,6 +138,7 @@ mesh.object = class MeshObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
rotation() {
|
rotation() {
|
||||||
|
throw "rotate() requires implementation";
|
||||||
let rotation = this.object.rotation;
|
let rotation = this.object.rotation;
|
||||||
if (arguments.length === 0) {
|
if (arguments.length === 0) {
|
||||||
return rotation;
|
return rotation;
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,6 @@ let model = {
|
||||||
if (x) geo.applyQuaternion(new Quaternion().setFromAxisAngle(new Vector3(1,0,0), x));
|
if (x) geo.applyQuaternion(new Quaternion().setFromAxisAngle(new Vector3(1,0,0), x));
|
||||||
if (y) geo.applyQuaternion(new Quaternion().setFromAxisAngle(new Vector3(0,1,0), y));
|
if (y) geo.applyQuaternion(new Quaternion().setFromAxisAngle(new Vector3(0,1,0), y));
|
||||||
if (z) geo.applyQuaternion(new Quaternion().setFromAxisAngle(new Vector3(0,0,1), z));
|
if (z) geo.applyQuaternion(new Quaternion().setFromAxisAngle(new Vector3(0,0,1), z));
|
||||||
console.log({ rec, data, geo: geo.attributes.position.array });
|
|
||||||
},
|
},
|
||||||
|
|
||||||
load(data) {
|
load(data) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue