make wireframe a global toggle
This commit is contained in:
parent
361b53c6d1
commit
f7d31b4ebb
4 changed files with 38 additions and 19 deletions
|
|
@ -279,7 +279,7 @@ function space_init(data) {
|
||||||
selection.focus();
|
selection.focus();
|
||||||
break;
|
break;
|
||||||
case 'KeyW':
|
case 'KeyW':
|
||||||
selection.wireframe({toggle:true}, {opacity:0.15});
|
api.wireframe({toggle:true}, {opacity:0.15});
|
||||||
break;
|
break;
|
||||||
case 'KeyB':
|
case 'KeyB':
|
||||||
selection.boundsBox({toggle:true});
|
selection.boundsBox({toggle:true});
|
||||||
|
|
|
||||||
|
|
@ -157,13 +157,6 @@ let selection = {
|
||||||
return selection;
|
return selection;
|
||||||
},
|
},
|
||||||
|
|
||||||
wireframe() {
|
|
||||||
for (let m of selection.models()) {
|
|
||||||
m.wireframe(...arguments);
|
|
||||||
}
|
|
||||||
return selection;
|
|
||||||
},
|
|
||||||
|
|
||||||
boundsBox() {
|
boundsBox() {
|
||||||
for (let m of selection.groups()) {
|
for (let m of selection.groups()) {
|
||||||
m.showBounds(...arguments);
|
m.showBounds(...arguments);
|
||||||
|
|
@ -240,6 +233,12 @@ let api = mesh.api = {
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
wireframe() {
|
||||||
|
for (let m of api.model.list()) {
|
||||||
|
m.wireframe(...arguments);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
selection,
|
selection,
|
||||||
|
|
||||||
group,
|
group,
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,8 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
meh.receiveShadow = true;
|
meh.receiveShadow = true;
|
||||||
meh.castShadow = true;
|
meh.castShadow = true;
|
||||||
meh.renderOrder = 1;
|
meh.renderOrder = 1;
|
||||||
|
// sets fallback opacity for wireframe toggle
|
||||||
|
this.opacity(1);
|
||||||
// this ref allows clicks to be traced to models and groups
|
// this ref allows clicks to be traced to models and groups
|
||||||
meh.model = this;
|
meh.model = this;
|
||||||
// sync data to worker
|
// sync data to worker
|
||||||
|
|
@ -139,11 +141,35 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
return this.vertices / 3;
|
return this.vertices / 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
opacity(ov) {
|
visible(bool) {
|
||||||
|
if (bool === undefined) {
|
||||||
|
return this.mesh.visible;
|
||||||
|
}
|
||||||
|
if (bool.toggle) {
|
||||||
|
return this.visible(!this.mesh.visible);
|
||||||
|
}
|
||||||
|
this.mesh.visible = bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
material(mat) {
|
||||||
|
let op = this.opacity();
|
||||||
|
this.mesh.material = mat = mat.clone();
|
||||||
|
mat.opacity = op;
|
||||||
|
if (op === 1) this.wireframe(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
opacity(ov, opt = {}) {
|
||||||
let mat = this.mesh.material;
|
let mat = this.mesh.material;
|
||||||
if (ov === undefined) {
|
if (ov === undefined) {
|
||||||
return mat.opacity;
|
return mat.opacity;
|
||||||
}
|
}
|
||||||
|
if (ov.restore) {
|
||||||
|
ov = this._op;
|
||||||
|
} else if (ov.temp !== undefined) {
|
||||||
|
ov = ov.temp;
|
||||||
|
} else {
|
||||||
|
this._op = ov;
|
||||||
|
}
|
||||||
if (ov <= 0.0) {
|
if (ov <= 0.0) {
|
||||||
mat.transparent = false;
|
mat.transparent = false;
|
||||||
mat.opacity = 1;
|
mat.opacity = 1;
|
||||||
|
|
@ -160,7 +186,7 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
if (bool === undefined) {
|
if (bool === undefined) {
|
||||||
return this._wire ? {
|
return this._wire ? {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
opacity: this._wireo,
|
opacity: this.opacity(),
|
||||||
color: this._wire ? this._wire.material.color : undefined,
|
color: this._wire ? this._wire.material.color : undefined,
|
||||||
} : {
|
} : {
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|
@ -172,22 +198,16 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
if (this._wire) {
|
if (this._wire) {
|
||||||
this.mesh.remove(this._wire);
|
this.mesh.remove(this._wire);
|
||||||
this._wire = undefined;
|
this._wire = undefined;
|
||||||
this.opacity(this._wireo);
|
this.opacity({restore: true});
|
||||||
}
|
}
|
||||||
if (bool) {
|
if (bool) {
|
||||||
this._wireo = this.opacity();
|
|
||||||
this._wire = new THREE.Mesh(this.mesh.geometry.shallowClone(), materials.wireframe);
|
this._wire = new THREE.Mesh(this.mesh.geometry.shallowClone(), materials.wireframe);
|
||||||
this.mesh.add(this._wire);
|
this.mesh.add(this._wire);
|
||||||
this.opacity(opt.opacity || 0);
|
this.opacity({temp: opt.opacity || 0});
|
||||||
}
|
}
|
||||||
space.update();
|
space.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
material(mat) {
|
|
||||||
this.wireframe(false);
|
|
||||||
this.mesh.material = mat;
|
|
||||||
}
|
|
||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
if (arguments.length === 0) {
|
if (arguments.length === 0) {
|
||||||
// direct call requires pass through group
|
// direct call requires pass through group
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ button:hover {
|
||||||
}
|
}
|
||||||
|
|
||||||
#selectlist .grid {
|
#selectlist .grid {
|
||||||
background-color: rgba(255,255,255,0.9);
|
background-color: rgba(255,255,255,0.8);
|
||||||
border: 1px solid rgba(0,0,0,0.15);
|
border: 1px solid rgba(0,0,0,0.15);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue