auto-fog in wireframe mode to make detailed close examination easier on busy models
This commit is contained in:
parent
26ed1447d0
commit
0a0f892c4e
2 changed files with 35 additions and 3 deletions
|
|
@ -120,6 +120,7 @@ const selection = {
|
|||
group.wireframe(prefs.map.space.wire || false);
|
||||
group.normals(prefs.map.space.norm || false);
|
||||
}
|
||||
api.updateFog();
|
||||
// prevent selection of model and its group
|
||||
let mgsel = selected.filter(s => s instanceof mesh.model).map(m => m.group);
|
||||
selected = selected.filter(sel => !mgsel.contains(sel)).filter(v => v);
|
||||
|
|
@ -647,7 +648,8 @@ const api = exports({
|
|||
},
|
||||
|
||||
wireframe(state = {toggle:true}, opt = { }) {
|
||||
let wire = prefs.map.space.wire;
|
||||
const mspace = prefs.map.space;
|
||||
let wire = mspace.wire;
|
||||
if (state.toggle) {
|
||||
wire = !wire;
|
||||
} else {
|
||||
|
|
@ -656,7 +658,17 @@ const api = exports({
|
|||
for (let m of model.list()) {
|
||||
m.wireframe(wire, opt);
|
||||
}
|
||||
prefs.save( prefs.map.space.wire = wire );
|
||||
prefs.save( mspace.wire = wire );
|
||||
api.updateFog();
|
||||
},
|
||||
|
||||
updateFog() {
|
||||
const mspace = prefs.map.space;
|
||||
if (mspace.wire) {
|
||||
space.scene.setFog(3, mspace.dark ? 0 : 0xffffff);
|
||||
} else {
|
||||
space.scene.setFog(false);
|
||||
}
|
||||
},
|
||||
|
||||
normals(state = {toggle:true}) {
|
||||
|
|
|
|||
|
|
@ -1044,7 +1044,26 @@ gapp.register("moto.space", [], (root, exports) => {
|
|||
return SCENE.remove(o);
|
||||
},
|
||||
|
||||
active: updateLastAction
|
||||
active: updateLastAction,
|
||||
|
||||
setFog: function(mult, color) {
|
||||
if (mult) {
|
||||
SCENE.fog = new THREE.Fog(color, 100, 1000);
|
||||
SCENE.fog.mult = mult > 0 ? mult : 3;
|
||||
} else {
|
||||
SCENE.fog = undefined;
|
||||
}
|
||||
Space.scene.updateFog();
|
||||
},
|
||||
|
||||
updateFog: function() {
|
||||
const { fog } = SCENE;
|
||||
if (fog) {
|
||||
const dist = camera.position.distanceTo(viewControl.target);
|
||||
fog.near = dist;
|
||||
fog.far = dist * fog.mult;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
world: {
|
||||
|
|
@ -1230,6 +1249,7 @@ gapp.register("moto.space", [], (root, exports) => {
|
|||
if (moved && platformOnMove) {
|
||||
clearTimeout(platformMoveTimer);
|
||||
platformMoveTimer = setTimeout(platformOnMove, 500);
|
||||
Space.scene.updateFog();
|
||||
}
|
||||
updateLastAction();
|
||||
}, (val) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue