点击选择纹理。

This commit is contained in:
liteng 2018-12-15 16:37:15 +08:00
parent 6064c365a3
commit 94df1ce478
2 changed files with 15 additions and 13 deletions

View File

@ -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);
};
// ----------------------------------- 上传 ----------------------------------------

View File

@ -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();
});