mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-02-01 16:08:17 +00:00
平移旋转缩放事件优化。
This commit is contained in:
parent
021bdaa895
commit
fd38570df7
@ -8,6 +8,9 @@ import UI2 from '../ui2/UI';
|
||||
function Viewport(app) {
|
||||
this.app = app;
|
||||
var editor = this.app.editor;
|
||||
var _this = this;
|
||||
|
||||
// 用户界面
|
||||
|
||||
var container = new UI2.Div({
|
||||
parent: this.app.container,
|
||||
@ -18,10 +21,9 @@ function Viewport(app) {
|
||||
|
||||
container.render();
|
||||
|
||||
this.viewportInfo = new ViewportInfo(app, container);
|
||||
this.viewportInfo = new ViewportInfo(this.app, this.container);
|
||||
|
||||
//
|
||||
var _this = this;
|
||||
|
||||
var renderer = null;
|
||||
|
||||
@ -55,19 +57,8 @@ function Viewport(app) {
|
||||
// 平移旋转缩放控件
|
||||
|
||||
var transformControls = new THREE.TransformControls(camera, container.dom);
|
||||
editor.transformControls = transformControls;
|
||||
|
||||
transformControls.addEventListener('change', function () {
|
||||
_this.app.call('transformControlsChange', _this);
|
||||
});
|
||||
transformControls.addEventListener('mouseDown', function () {
|
||||
_this.app.call('transformControlsMouseDown', _this);
|
||||
});
|
||||
transformControls.addEventListener('mouseUp', function () {
|
||||
_this.app.call('transformControlsMouseUp', _this);
|
||||
});
|
||||
|
||||
sceneHelpers.add(transformControls);
|
||||
editor.transformControls = transformControls;
|
||||
|
||||
// 编辑器控件
|
||||
|
||||
|
||||
@ -19,22 +19,19 @@ TransformControlsEvent.prototype = Object.create(BaseEvent.prototype);
|
||||
TransformControlsEvent.prototype.constructor = TransformControlsEvent;
|
||||
|
||||
TransformControlsEvent.prototype.start = function () {
|
||||
var _this = this;
|
||||
this.app.on('transformControlsChange.' + this.id, function () {
|
||||
_this.onChange();
|
||||
});
|
||||
this.app.on('transformControlsMouseDown.' + this.id, function () {
|
||||
_this.onMouseDown();
|
||||
});
|
||||
this.app.on('transformControlsMouseUp.' + this.id, function () {
|
||||
_this.onMouseUp();
|
||||
});
|
||||
var transformControls = this.app.editor.transformControls;
|
||||
|
||||
transformControls.addEventListener('change', this.onChange.bind(this));
|
||||
transformControls.addEventListener('mouseDown', this.onMouseDown.bind(this));
|
||||
transformControls.addEventListener('mouseUp', this.onMouseUp.bind(this));
|
||||
};
|
||||
|
||||
TransformControlsEvent.prototype.stop = function () {
|
||||
this.app.on('transformControlsChange.' + this.id, null);
|
||||
this.app.on('transformControlsMouseDown.' + this.id, null);
|
||||
this.app.on('transformControlsMouseUp.' + this.id, null);
|
||||
var transformControls = this.app.editor.transformControls;
|
||||
|
||||
transformControls.removeEventListener('change', this.onChange);
|
||||
transformControls.removeEventListener('mouseDown', this.onMouseDown);
|
||||
transformControls.removeEventListener('mouseUp', this.onMouseUp);
|
||||
};
|
||||
|
||||
TransformControlsEvent.prototype.onChange = function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user