diff --git a/src/editor/menubar/AssetMenu.js b/src/editor/menubar/AssetMenu.js index 992a17f4..8f3dc07f 100644 --- a/src/editor/menubar/AssetMenu.js +++ b/src/editor/menubar/AssetMenu.js @@ -27,9 +27,17 @@ AssetMenu.prototype.render = function () { xtype: 'div', cls: 'options', children: [{ + xtype: 'div', + id: 'mAddAsset', + html: '添加模型', + cls: 'option', + onClick: function () { + _this.app.call('mAddAsset'); + } + }, { xtype: 'div', id: 'mImportAsset', - html: '导入', + html: '导入模型', cls: 'option', onClick: function () { _this.app.call('mImportAsset'); diff --git a/src/event/EventDispatcher.js b/src/event/EventDispatcher.js index b22ea1ed..4f862bfe 100644 --- a/src/event/EventDispatcher.js +++ b/src/event/EventDispatcher.js @@ -78,6 +78,7 @@ import AddHemisphereLightEvent from './menu/add/AddHemisphereLightEvent'; import AddAmbientLightEvent from './menu/add/AddAmbientLightEvent'; import AddPerspectiveCameraEvent from './menu/add/AddPerspectiveCameraEvent'; +import AddAssetEvent from './menu/asset/AddAssetEvent'; import ImportAssetEvent from './menu/asset/ImportAssetEvent'; import ExportGeometryEvent from './menu/asset/ExportGeometryEvent'; import ExportObjectEvent from './menu/asset/ExportObjectEvent'; @@ -222,6 +223,7 @@ function EventDispatcher(app) { new AddAmbientLightEvent(this.app), new AddPerspectiveCameraEvent(this.app), + new AddAssetEvent(this.app), new ImportAssetEvent(this.app), new ExportGeometryEvent(this.app), new ExportObjectEvent(this.app), diff --git a/src/event/EventList.js b/src/event/EventList.js index a138f74f..fe5775b6 100644 --- a/src/event/EventList.js +++ b/src/event/EventList.js @@ -56,6 +56,7 @@ var EventList = [ 'mAddAmbientLight', // 添加环境光 'mAddPerspectiveCamera', // 添加透视相机 + 'mAddAsset', // 添加模型 'mImportAsset', // 导入资源 'mExportGeometry', // 导出几何体 'mExportObject', // 导出物体 diff --git a/src/event/menu/asset/AddAssetEvent.js b/src/event/menu/asset/AddAssetEvent.js new file mode 100644 index 00000000..68c982e1 --- /dev/null +++ b/src/event/menu/asset/AddAssetEvent.js @@ -0,0 +1,32 @@ +import MenuEvent from '../MenuEvent'; + +/** + * 添加资源事件 + * @param {*} app + */ +function AddAssetEvent(app) { + MenuEvent.call(this, app); +} + +AddAssetEvent.prototype = Object.create(MenuEvent.prototype); +AddAssetEvent.prototype.constructor = AddAssetEvent; + +AddAssetEvent.prototype.start = function () { + var _this = this; + this.app.on('mAddAsset.' + this.id, function () { + _this.onAddAsset(); + }); +}; + +AddAssetEvent.prototype.stop = function () { + this.app.on('mAddAsset.' + this.id, null); +}; + +AddAssetEvent.prototype.onAddAsset = function () { + var btn = UI.get('modelBtn'); + if (btn) { + btn.dom.click(); + } +}; + +export default AddAssetEvent; \ No newline at end of file diff --git a/src/ui/ImageList.js b/src/ui/ImageList.js index e413b3f9..9f3c7a0f 100644 --- a/src/ui/ImageList.js +++ b/src/ui/ImageList.js @@ -63,6 +63,9 @@ ImageList.prototype.render = function () { obj.onClick = onClick.bind(this); obj.render(); obj.dom.dataIndex = i; // 序号 + obj.img.dataIndex = i; + obj.editBtn.dom.dataIndex = i; + obj.deleteBtn.dom.dataIndex = i; // 说明 var description = document.createElement('div');