mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-02-01 16:08:17 +00:00
主题改变事件。
This commit is contained in:
parent
f0c5323c58
commit
afc6026841
@ -108,25 +108,6 @@ function Viewport(app) {
|
||||
vrEffect.isPresenting ? vrEffect.exitPresent() : vrEffect.requestPresent();
|
||||
});
|
||||
|
||||
this.app.on('themeChanged.Viewport', function (value) {
|
||||
switch (value) {
|
||||
case 'assets/css/light.css':
|
||||
sceneHelpers.remove(grid);
|
||||
grid = new THREE.GridHelper(60, 60, 0x444444, 0x888888);
|
||||
sceneHelpers.add(grid);
|
||||
editor.grid = grid;
|
||||
break;
|
||||
case 'assets/css/dark.css':
|
||||
sceneHelpers.remove(grid);
|
||||
grid = new THREE.GridHelper(60, 60, 0xbbbbbb, 0x888888);
|
||||
sceneHelpers.add(grid);
|
||||
editor.grid = grid;
|
||||
break;
|
||||
}
|
||||
|
||||
_this.app.call('render');
|
||||
});
|
||||
|
||||
this.app.call('animate');
|
||||
};
|
||||
|
||||
|
||||
@ -93,6 +93,7 @@ import GeometryEvent from './viewport/GeometryEvent';
|
||||
import PickEvent from './viewport/PickEvent';
|
||||
import RendererChangedEvent from './viewport/RendererChangedEvent';
|
||||
import WindowResizeEvent from './viewport/WindowResizeEvent';
|
||||
import ThemeChangedEvent from './viewport/ThemeChangedEvent';
|
||||
|
||||
import TransformModeChangedEvent from './statusBar/TransformModeChangedEvent';
|
||||
import GridChangeEvent from './statusBar/GridChangeEvent';
|
||||
@ -202,6 +203,7 @@ function EventDispatcher(app) {
|
||||
new PickEvent(this.app),
|
||||
new RendererChangedEvent(this.app),
|
||||
new WindowResizeEvent(this.app),
|
||||
new ThemeChangedEvent(this.app),
|
||||
|
||||
// statusBar中的事件
|
||||
new TransformModeChangedEvent(this.app),
|
||||
|
||||
45
src/event/viewport/ThemeChangedEvent.js
Normal file
45
src/event/viewport/ThemeChangedEvent.js
Normal file
@ -0,0 +1,45 @@
|
||||
import BaseEvent from '../BaseEvent';
|
||||
|
||||
/**
|
||||
* 主题改变事件
|
||||
* @param {*} app
|
||||
*/
|
||||
function ThemeChangedEvent(app) {
|
||||
BaseEvent.call(this, app);
|
||||
}
|
||||
|
||||
ThemeChangedEvent.prototype = Object.create(BaseEvent.prototype);
|
||||
ThemeChangedEvent.prototype.constructor = ThemeChangedEvent;
|
||||
|
||||
ThemeChangedEvent.prototype.start = function () {
|
||||
this.app.on('themeChanged.' + this.id, this.onThemeChanged.bind(this));
|
||||
};
|
||||
|
||||
ThemeChangedEvent.prototype.stop = function () {
|
||||
this.app.on('themeChanged.' + this.id, null);
|
||||
};
|
||||
|
||||
ThemeChangedEvent.prototype.onThemeChanged = function (value) {
|
||||
var editor = this.app.editor;
|
||||
var sceneHelpers = editor.sceneHelpers;
|
||||
var grid = editor.grid;
|
||||
|
||||
switch (value) {
|
||||
case 'assets/css/light.css':
|
||||
sceneHelpers.remove(grid);
|
||||
grid = new THREE.GridHelper(60, 60, 0x444444, 0x888888);
|
||||
sceneHelpers.add(grid);
|
||||
editor.grid = grid;
|
||||
break;
|
||||
case 'assets/css/dark.css':
|
||||
sceneHelpers.remove(grid);
|
||||
grid = new THREE.GridHelper(60, 60, 0xbbbbbb, 0x888888);
|
||||
sceneHelpers.add(grid);
|
||||
editor.grid = grid;
|
||||
break;
|
||||
}
|
||||
|
||||
this.app.call('render');
|
||||
};
|
||||
|
||||
export default ThemeChangedEvent;
|
||||
Loading…
x
Reference in New Issue
Block a user