From 94df1ce478ba75b86cac2cce5ff79e29464ecc86 Mon Sep 17 00:00:00 2001 From: liteng <930372551@qq.com> Date: Sat, 15 Dec 2018 16:37:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=B9=E5=87=BB=E9=80=89=E6=8B=A9=E7=BA=B9?= =?UTF-8?q?=E7=90=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/editor/bottom/MapPanel.js | 4 ++-- .../editor/control/TextureSelectControl.js | 24 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ShadowEditor.Web/src/editor/bottom/MapPanel.js b/ShadowEditor.Web/src/editor/bottom/MapPanel.js index c23e2fa5..16a60597 100644 --- a/ShadowEditor.Web/src/editor/bottom/MapPanel.js +++ b/ShadowEditor.Web/src/editor/bottom/MapPanel.js @@ -209,8 +209,8 @@ MapPanel.prototype.onClick = function (event, index, btn, control) { // ------------------------------------- 添加 ------------------------------------ -MapPanel.prototype.onAddMap = function (model) { - UI.msg('添加成功!'); +MapPanel.prototype.onAddMap = function (data) { + this.app.call(`selectMap`, this, data); }; // ----------------------------------- 上传 ---------------------------------------- diff --git a/ShadowEditor.Web/src/editor/control/TextureSelectControl.js b/ShadowEditor.Web/src/editor/control/TextureSelectControl.js index 96570984..e75f9af2 100644 --- a/ShadowEditor.Web/src/editor/control/TextureSelectControl.js +++ b/ShadowEditor.Web/src/editor/control/TextureSelectControl.js @@ -1,16 +1,16 @@ import Control from '../../ui/Control'; -import TextureWindow from '../window/TextureWindow'; /** * 纹理选择控件 * @param {*} options */ -function TextureSelectControl(options) { +function TextureSelectControl(options = {}) { Control.call(this, options); this.app = options.app; this.texture = null; + this.isSelecting = false; this.onChange = options.onChange || null; } @@ -75,17 +75,21 @@ TextureSelectControl.prototype.setValue = function (texture) { }; TextureSelectControl.prototype.onClick = function () { - if (this.window === undefined) { - this.window = new TextureWindow({ - app: this.app, - onSelect: this.onSelect.bind(this) - }); - this.window.render(); + this.app.call(`selectBottomPanel`, this, 'map'); + UI.msg(`请点击贴图面板中的贴图!`); + + if (this.isSelecting) { + return; } - this.window.show(); + + this.isSelecting = true; + this.app.on(`selectMap.${this.id}`, this.onSelect.bind(this)); }; TextureSelectControl.prototype.onSelect = function (data) { + this.isSelecting = false; + this.app.on(`selectMap.${this.id}`, null); + var urls = data.Url.split(';'); // 立体贴图data.Url多于一张,只取第一个。 if (data.Type === 'video') { // 视频贴图 @@ -100,7 +104,6 @@ TextureSelectControl.prototype.onSelect = function (data) { texture.format = THREE.RGBFormat; this.texture = texture; this.texture.name = data.Name; - this.window.hide(); this.updateUI(); this.onChange(); } @@ -109,7 +112,6 @@ TextureSelectControl.prototype.onSelect = function (data) { loader.load(`${this.app.options.server}${urls[0]}`, texture => { this.texture = texture; this.texture.name = data.Name; - this.window.hide(); this.updateUI(); this.onChange(); });