mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
新增选中帮助器。
This commit is contained in:
parent
c62faecf63
commit
784ecfafe0
@ -1,6 +1,7 @@
|
||||
import BaseHelper from './BaseHelper';
|
||||
import GridHelper from './GridHelper';
|
||||
import ViewHelper from './ViewHelper';
|
||||
import SelectHelper from './SelectHelper';
|
||||
import SplineHelper from './line/SplineHelper';
|
||||
|
||||
/**
|
||||
@ -13,6 +14,7 @@ function Helpers(app) {
|
||||
this.helpers = [
|
||||
new GridHelper(app),
|
||||
new ViewHelper(app),
|
||||
new SelectHelper(app),
|
||||
new SplineHelper(app),
|
||||
];
|
||||
}
|
||||
|
||||
@ -12,11 +12,37 @@ SelectHelper.prototype = Object.create(BaseHelper.prototype);
|
||||
SelectHelper.prototype.constructor = SelectHelper;
|
||||
|
||||
SelectHelper.prototype.start = function () {
|
||||
|
||||
this.app.on(`objectSelected.${this.id}`, this.onObjectSelected.bind(this));
|
||||
this.app.on(`objectChanged.${this.id}`, this.onObjectChanged.bind(this));
|
||||
};
|
||||
|
||||
SelectHelper.prototype.stop = function () {
|
||||
this.app.on(`objectSelected.${this.id}`, null);
|
||||
this.app.on(`objectChanged.${this.id}`, null);
|
||||
};
|
||||
|
||||
SelectHelper.prototype.onObjectSelected = function (obj) {
|
||||
if (this.helper === undefined) {
|
||||
this.helper = new THREE.BoxHelper();
|
||||
this.helper.visible = false;
|
||||
this.app.editor.sceneHelpers.add(this.helper);
|
||||
}
|
||||
|
||||
if (obj) {
|
||||
this.object = obj;
|
||||
this.helper.setFromObject(obj);
|
||||
this.helper.visible = true;
|
||||
} else {
|
||||
delete this.object;
|
||||
this.helper.setFromObject(undefined);
|
||||
this.helper.visible = false;
|
||||
}
|
||||
};
|
||||
|
||||
SelectHelper.prototype.onObjectChanged = function (obj) {
|
||||
if (this.object && this.helper && this.object === obj) {
|
||||
this.helper.update();
|
||||
}
|
||||
};
|
||||
|
||||
export default SelectHelper;
|
||||
Loading…
x
Reference in New Issue
Block a user