保存场景记录选中状态。

This commit is contained in:
liteng 2018-12-17 19:32:03 +08:00
parent 9889fbaeba
commit 049607d9fa
2 changed files with 15 additions and 0 deletions

View File

@ -338,6 +338,15 @@ ScenePanel.prototype.onLoadScene = function (obj) {
this.app.editor.camera.updateProjectionMatrix();
if (obj.options.selected) {
var obj = this.app.editor.objectByUuid(obj.options.selected);
if (obj) {
this.app.editor.select(obj);
} else {
console.warn(`ScenePanel: 无法选中uuid为${obj.options.selected}的物体!`);
}
}
this.app.call('sceneLoaded', this);
};

View File

@ -95,6 +95,12 @@ SceneMenu.prototype.saveScene = function () { // 保存场景
SceneMenu.prototype.commitSave = function (sceneName) {
var editor = this.app.editor;
// 记录选中物体,以便载入时还原场景选中
var selected = this.app.editor.selected;
if (selected) {
this.app.options.selected = selected.uuid;
}
var obj = (new Converter()).toJSON({
options: this.app.options,
camera: editor.camera,