mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
点击场景选中模型时,场景树状图优先选中整个模型,而不是模型的一部分,而且会自动展开并滚动到所选模型。
This commit is contained in:
parent
3559010720
commit
cf463e8798
@ -25,6 +25,7 @@ Language: 中文 / [English](README-en.md)
|
||||
15. 修复创建脚本注释未汉化bug。
|
||||
16. 折叠底部面板功能。
|
||||
17. 重写场景树状图控件,支持折叠,暂时不支持拖拽。
|
||||
18. 点击场景选中模型时,场景树状图优先选中整个模型,而不是模型的一部分,而且会自动展开并滚动到所选模型。
|
||||
|
||||
## v0.1.5更新
|
||||
|
||||
|
||||
@ -101,7 +101,7 @@ PickEvent.prototype.handleClick = function () {
|
||||
// helper
|
||||
editor.select(object.userData.object);
|
||||
} else {
|
||||
editor.select(object);
|
||||
editor.select(this.partToMesh(object));
|
||||
}
|
||||
} else {
|
||||
editor.select(null);
|
||||
@ -121,4 +121,38 @@ PickEvent.prototype.handleClick = function () {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 如果选中的是模型的一部分,改为选择整个模型
|
||||
* @param {*} obj
|
||||
*/
|
||||
PickEvent.prototype.partToMesh = function (obj) {
|
||||
var scene = this.app.editor.scene;
|
||||
|
||||
if (obj === scene || obj.userData && obj.userData.Server === true) { // 场景或服务端模型
|
||||
return obj;
|
||||
}
|
||||
|
||||
// 判断obj是否是模型的一部分
|
||||
var model = obj;
|
||||
var isPart = false;
|
||||
|
||||
while (model) {
|
||||
if (model === scene) {
|
||||
break;
|
||||
}
|
||||
if (model.userData && model.userData.Server === true) {
|
||||
isPart = true;
|
||||
break;
|
||||
}
|
||||
|
||||
model = model.parent;
|
||||
}
|
||||
|
||||
if (isPart) {
|
||||
return model;
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
export default PickEvent;
|
||||
@ -240,15 +240,18 @@ Tree.prototype.select = function (value) {
|
||||
/**
|
||||
* 展开选中的节点的所有父节点
|
||||
* @param {*} dom
|
||||
* @param {*} isParent
|
||||
*/
|
||||
Tree.prototype._expandSelected = function (dom) {
|
||||
Tree.prototype._expandSelected = function (dom, isParent = false) {
|
||||
if (dom.classList.contains('Tree')) { // 根节点,默认展开
|
||||
return;
|
||||
} else if (dom.classList.contains('SubTree')) { // 子树,展开父节点
|
||||
this._expandSelected(dom.parentNode);
|
||||
this._expandSelected(dom.parentNode, true);
|
||||
} else if (dom.classList.contains('Node')) { // 节点,展开
|
||||
this.expand(dom.data.value);
|
||||
this._expandSelected(dom.parentNode);
|
||||
if (isParent) {
|
||||
this.expand(dom.data.value);
|
||||
}
|
||||
this._expandSelected(dom.parentNode, true);
|
||||
} else {
|
||||
console.warn(`Tree: Unknown node.`);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user