源码和关于事件。

This commit is contained in:
liteng 2018-06-22 22:27:05 +08:00
parent a665140f8c
commit aed6643e39
4 changed files with 64 additions and 49 deletions

View File

@ -77,6 +77,9 @@ import VRModeEvent from './menu/view/VRModeEvent';
import ExampleEvent from './menu/example/ExampleEvent';
import SourceCodeEvent from './menu/help/SourceCodeEvent';
import AboutEvent from './menu/help/AboutEvent';
/**
* 事件执行器
*/
@ -162,6 +165,9 @@ function EventDispatcher(app) {
new VRModeEvent(this.app),
new ExampleEvent(this.app),
new SourceCodeEvent(this.app),
new AboutEvent(this.app),
];
}

View File

@ -0,0 +1,29 @@
import MenuEvent from '../MenuEvent';
/**
* 关于事件
* @param {*} app
*/
function AboutEvent(app) {
MenuEvent.call(this, app);
}
AboutEvent.prototype = Object.create(MenuEvent.prototype);
AboutEvent.prototype.constructor = AboutEvent;
AboutEvent.prototype.start = function () {
var _this = this;
this.app.on('mAbout.' + this.id, function () {
_this.onAbout();
});
};
AboutEvent.prototype.stop = function () {
this.app.on('mAbout.' + this.id, null);
};
AboutEvent.prototype.onAbout = function () {
window.open('http://threejs.org', '_blank');
};
export default AboutEvent;

View File

@ -0,0 +1,29 @@
import MenuEvent from '../MenuEvent';
/**
* 源码事件
* @param {*} app
*/
function SourceCodeEvent(app) {
MenuEvent.call(this, app);
}
SourceCodeEvent.prototype = Object.create(MenuEvent.prototype);
SourceCodeEvent.prototype.constructor = SourceCodeEvent;
SourceCodeEvent.prototype.start = function () {
var _this = this;
this.app.on('mSourceCode.' + this.id, function () {
_this.onSourceCode();
});
};
SourceCodeEvent.prototype.stop = function () {
this.app.on('mSourceCode.' + this.id, null);
};
SourceCodeEvent.prototype.onSourceCode = function () {
window.open('https://github.com/mrdoob/three.js/tree/master/editor', '_blank');
};
export default SourceCodeEvent;

View File

@ -1,49 +0,0 @@
import UI from '../ui/UI';
/**
* @author mrdoob / http://mrdoob.com/
*/
function HelpMenu(editor) {
var container = new UI.Panel();
container.setClass('menu');
var title = new UI.Panel();
title.setClass('title');
title.setTextContent('帮助');
container.add(title);
var options = new UI.Panel();
options.setClass('options');
container.add(options);
// Source code
var option = new UI.Row();
option.setClass('option');
option.setTextContent('源码');
option.onClick(function () {
window.open('https://github.com/mrdoob/three.js/tree/master/editor', '_blank')
});
options.add(option);
// About
var option = new UI.Row();
option.setClass('option');
option.setTextContent('关于');
option.onClick(function () {
window.open('http://threejs.org', '_blank');
});
options.add(option);
return container;
};
export default HelpMenu;