add setFocus() and multi-use 'v' key to refocus on center of all widgets
This commit is contained in:
parent
be8e2054d4
commit
cbc9fb8da3
4 changed files with 48 additions and 8 deletions
|
|
@ -414,6 +414,9 @@
|
|||
API.show.local();
|
||||
break;
|
||||
case cca('v'): // toggle single slice view mode
|
||||
if (API.view.get() === VIEWS.ARRANGE) {
|
||||
API.space.set_focus();
|
||||
}
|
||||
if (API.var.layer_hi == API.var.layer_lo) {
|
||||
API.var.layer_lo = 0;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -327,7 +327,8 @@
|
|||
reload: reload,
|
||||
restore: restoreWorkspace,
|
||||
clear: clearWorkspace,
|
||||
save: saveWorkspace
|
||||
save: saveWorkspace,
|
||||
set_focus: setFocus
|
||||
},
|
||||
tweak,
|
||||
util: {
|
||||
|
|
@ -368,6 +369,25 @@
|
|||
work: KIRI.work
|
||||
};
|
||||
|
||||
function setFocus(widgets) {
|
||||
if (widgets === undefined) {
|
||||
widgets = WIDGETS;
|
||||
} else if (!Array.isArray) {
|
||||
widgets = [ widgets ];
|
||||
}
|
||||
let pos = { x:0, y:0, z:0 };
|
||||
for (let widget of widgets) {
|
||||
pos.x += widget.track.pos.x;
|
||||
pos.y += widget.track.pos.y;
|
||||
pos.z += widget.track.pos.z;
|
||||
}
|
||||
pos.x /= widgets.length;
|
||||
pos.y /= widgets.length;
|
||||
pos.z /= widgets.length;
|
||||
SPACE.platform.setCenter(pos.x, -pos.y, pos.z);
|
||||
SPACE.view.setFocus(new THREE.Vector3(pos.x, pos.z, -pos.y));
|
||||
}
|
||||
|
||||
function reload() {
|
||||
API.event.emit('reload');
|
||||
do_reload(100);
|
||||
|
|
|
|||
|
|
@ -181,6 +181,15 @@ MOTO.CTRL = function (object, domElement, notify, slider) {
|
|||
}
|
||||
};
|
||||
|
||||
this.getTarget = function() {
|
||||
return this.target;
|
||||
};
|
||||
|
||||
this.setTarget = function(t) {
|
||||
this.target = t;
|
||||
this.target0 = this.target.clone();
|
||||
}
|
||||
|
||||
function isValue(v) {
|
||||
return v !== null && v !== undefined;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@
|
|||
PI2 = PI / 2,
|
||||
PI4 = PI / 4,
|
||||
ROUND = Math.round,
|
||||
panX = 0,
|
||||
panY = 0,
|
||||
panZ = 0,
|
||||
gridZOff = 0,
|
||||
platformZOff = 0,
|
||||
perspective = 35,
|
||||
|
|
@ -896,6 +898,7 @@
|
|||
add: function(o) { WORLD.add(o) },
|
||||
remove: function(o) { WORLD.remove(o) },
|
||||
setMaxZ: function(z) { panY = z / 2 },
|
||||
setCenter: function(x,y,z) { panX = x; panY = z, panZ = y },
|
||||
isHidden: function() { return !showPlatform },
|
||||
setHidden: function(b) { showPlatform = !b; platform.visible = !b },
|
||||
setHiding: function(b) { hidePlatformBelow = b },
|
||||
|
|
@ -935,12 +938,12 @@
|
|||
},
|
||||
|
||||
view: {
|
||||
top: function() { tweenCam({left: 0, up: 0, panX: 0, panY: panY, panZ: 0}) },
|
||||
back: function() { tweenCam({left: PI, up: PI2, panX: 0, panY: panY, panZ: 0}) },
|
||||
home: function() { tweenCam({left: 0, up: PI4, panX: 0, panY: panY, panZ: 0}) },
|
||||
front: function() { tweenCam({left: 0, up: PI2, panX: 0, panY: panY, panZ: 0}) },
|
||||
right: function() { tweenCam({left: PI2, up: PI2, panX: 0, panY: panY, panZ: 0}) },
|
||||
left: function() { tweenCam({left: -PI2, up: PI2, panX: 0, panY: panY, panZ: 0}) },
|
||||
top: function() { tweenCam({left: 0, up: 0, panX, panY, panZ}) },
|
||||
back: function() { tweenCam({left: PI, up: PI2, panX, panY, panZ}) },
|
||||
home: function() { tweenCam({left: 0, up: PI4, panX, panY, panZ}) },
|
||||
front: function() { tweenCam({left: 0, up: PI2, panX, panY, panZ}) },
|
||||
right: function() { tweenCam({left: PI2, up: PI2, panX, panY, panZ}) },
|
||||
left: function() { tweenCam({left: -PI2, up: PI2, panX, panY, panZ}) },
|
||||
reset: function() { viewControl.reset(); requestRefresh() },
|
||||
load: function(cam) { viewControl.setPosition(cam) },
|
||||
save: function() { return viewControl.getPosition(true) },
|
||||
|
|
@ -953,7 +956,12 @@
|
|||
viewControl.setMouse(viewControl.mouseDefault);
|
||||
}
|
||||
},
|
||||
getFPS: function() { return fps }
|
||||
getFPS: function() { return fps },
|
||||
getFocus: function() { return viewControl.getTarget() },
|
||||
setFocus: function(v) {
|
||||
viewControl.setTarget(v);
|
||||
refresh();
|
||||
},
|
||||
},
|
||||
|
||||
mouse: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue