change default wire view to edges and persist preference
This commit is contained in:
parent
96095a3870
commit
5650f25f3d
4 changed files with 27 additions and 13 deletions
|
|
@ -8,6 +8,7 @@ import '../add/three.js';
|
||||||
import '../mesh/build.js';
|
import '../mesh/build.js';
|
||||||
|
|
||||||
import { api } from '../mesh/api.js';
|
import { api } from '../mesh/api.js';
|
||||||
|
import { base } from '../geo/base.js';
|
||||||
import { space } from '../moto/space.js';
|
import { space } from '../moto/space.js';
|
||||||
import { broker } from '../moto/broker.js';
|
import { broker } from '../moto/broker.js';
|
||||||
import { $, $d, h, estop } from '../moto/webui.js';
|
import { $, $d, h, estop } from '../moto/webui.js';
|
||||||
|
|
@ -269,7 +270,13 @@ function space_init(data) {
|
||||||
case 'KeyV':
|
case 'KeyV':
|
||||||
return shiftKey ? selection.show() : selection.focus();
|
return shiftKey ? selection.show() : selection.focus();
|
||||||
case 'KeyW':
|
case 'KeyW':
|
||||||
return api.wireframe();
|
return shiftKey ?
|
||||||
|
api.wireframe() :
|
||||||
|
api.wireframe({
|
||||||
|
toggle: true
|
||||||
|
}, {
|
||||||
|
edges: base.util.toDegrees(api.prefs.map.surface.radians)
|
||||||
|
});
|
||||||
case 'KeyX':
|
case 'KeyX':
|
||||||
return api.file.export();
|
return api.file.export();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -183,8 +183,9 @@ const selection = {
|
||||||
group.select(false);
|
group.select(false);
|
||||||
group.normals(prefs.map.space.norm || false);
|
group.normals(prefs.map.space.norm || false);
|
||||||
group.wireframe(prefs.map.space.wire || false, {
|
group.wireframe(prefs.map.space.wire || false, {
|
||||||
opacity: prefs.map.wireframe.opacity}
|
opacity: prefs.map.wireframe.opacity,
|
||||||
);
|
edges: prefs.map.space.wire_edge
|
||||||
|
});
|
||||||
}
|
}
|
||||||
for (let sketch of sketches) {
|
for (let sketch of sketches) {
|
||||||
sketch.select(false);
|
sketch.select(false);
|
||||||
|
|
@ -1533,7 +1534,7 @@ const api = {
|
||||||
if (isNaN(center.x * center.y * center.z)) {
|
if (isNaN(center.x * center.y * center.z)) {
|
||||||
center = { x: 0, y: 0, z: 0 };
|
center = { x: 0, y: 0, z: 0 };
|
||||||
}
|
}
|
||||||
let { normal } = object.object;
|
let { normal } = Array.isArray(object) ? object[0].object : object.object;
|
||||||
let left, up;
|
let left, up;
|
||||||
if (normal) {
|
if (normal) {
|
||||||
let { x, y, z } = normal;
|
let { x, y, z } = normal;
|
||||||
|
|
@ -1559,9 +1560,12 @@ const api = {
|
||||||
save();
|
save();
|
||||||
},
|
},
|
||||||
|
|
||||||
wireframe(state = { toggle:true }, opt = { opacity: prefs.map.wireframe.opacity }) {
|
wireframe(state = { toggle:true }, opt = {
|
||||||
|
opacity: prefs.map.wireframe.opacity,
|
||||||
|
edges: prefs.map.space.wire_edge
|
||||||
|
}) {
|
||||||
const mspace = prefs.map.space;
|
const mspace = prefs.map.space;
|
||||||
let wire = mspace.wire;
|
let { wire } = mspace;
|
||||||
if (state.toggle) {
|
if (state.toggle) {
|
||||||
wire = !wire;
|
wire = !wire;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1570,7 +1574,9 @@ const api = {
|
||||||
for (let m of model.list()) {
|
for (let m of model.list()) {
|
||||||
m.wireframe(wire, opt);
|
m.wireframe(wire, opt);
|
||||||
}
|
}
|
||||||
prefs.save( mspace.wire = wire );
|
mspace.wire = wire;
|
||||||
|
mspace.wire_edge = wire ? opt.edges : 0;
|
||||||
|
prefs.save();
|
||||||
api.updateFog();
|
api.updateFog();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -1645,6 +1651,8 @@ function log() {
|
||||||
|
|
||||||
const call = broker.send;
|
const call = broker.send;
|
||||||
|
|
||||||
|
self.mesh_api = api;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
sketches,
|
sketches,
|
||||||
selection,
|
selection,
|
||||||
|
|
|
||||||
|
|
@ -449,12 +449,13 @@ class MeshModel extends meshObject {
|
||||||
}
|
}
|
||||||
if (was) {
|
if (was) {
|
||||||
this.mesh.remove(this._wire);
|
this.mesh.remove(this._wire);
|
||||||
|
this._wire?.geometry.dispose();
|
||||||
this._wire = undefined;
|
this._wire = undefined;
|
||||||
this.opacity({restore: true});
|
this.opacity({restore: true});
|
||||||
}
|
}
|
||||||
if (bool === 'edges') {
|
if (bool && opt.edges) {
|
||||||
let edges = new THREE.EdgesGeometry(this.mesh.geometry, 5);
|
let edges = new THREE.EdgesGeometry(this.mesh.geometry, opt.edges);
|
||||||
this._wire = new THREE.LineSegments(edges, materials.wireframe);
|
this._wire = new THREE.LineSegments(edges, materials.wireline);
|
||||||
this.mesh.add(this._wire);
|
this.mesh.add(this._wire);
|
||||||
this.opacity({temp: opt.opacity || 0.15});
|
this.opacity({temp: opt.opacity || 0.15});
|
||||||
} else if (bool) {
|
} else if (bool) {
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,9 @@
|
||||||
|
|
||||||
import { THREE } from '../ext/three.js';
|
import { THREE } from '../ext/three.js';
|
||||||
import { api as meshApi } from './api.js';
|
import { api as meshApi } from './api.js';
|
||||||
import { object as meshObject } from './object.js';
|
|
||||||
|
|
||||||
const { Matrix4, Matrix3, Vector3, Box3, LineSegments, BufferGeometry, Float32BufferAttribute, LineBasicMaterial } = THREE;
|
const { Matrix3, Vector3, Box3, LineSegments, BufferGeometry, Float32BufferAttribute, LineBasicMaterial } = THREE;
|
||||||
const deferFn = [];
|
const deferFn = [];
|
||||||
const boundsCache = {};
|
|
||||||
|
|
||||||
// util functions augmented in build (download)
|
// util functions augmented in build (download)
|
||||||
const util = {
|
const util = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue