场景组件。

This commit is contained in:
liteng 2018-09-11 07:50:39 +08:00
parent 6fa2e9e2f6
commit c8acc22140
2 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,69 @@
import BaseComponent from './BaseComponent';
import SetValueCommand from '../command/SetValueCommand';
/**
* 场景组件
* @author tengge / https://github.com/tengge1
* @param {*} options
*/
function SceneComponent(options) {
BaseComponent.call(this, options);
this.selected = null;
}
SceneComponent.prototype = Object.create(BaseComponent.prototype);
SceneComponent.prototype.constructor = SceneComponent;
SceneComponent.prototype.render = function () {
var data = {
xtype: 'div',
id: 'scenePanel',
scope: this.id,
parent: this.parent,
cls: 'Panel',
style: {
borderTop: 0,
display: 'none'
},
children: [{
xtype: 'row',
children: [{
xtype: 'label',
style: {
color: '#555',
fontWeight: 'bold'
},
text: '场景组件'
}]
}]
};
var control = UI.create(data);
control.render();
this.app.on(`objectSelected.${this.id}`, this.onObjectSelected.bind(this));
this.app.on(`objectChanged.${this.id}`, this.onObjectChanged.bind(this));
};
SceneComponent.prototype.onObjectSelected = function () {
this.updateUI();
};
SceneComponent.prototype.onObjectChanged = function () {
this.updateUI();
};
SceneComponent.prototype.updateUI = function () {
var container = UI.get('scenePanel', this.id);
var editor = this.app.editor;
if (editor.selected && editor.selected instanceof THREE.Scene) {
container.dom.style.display = '';
} else {
container.dom.style.display = 'none';
return;
}
this.selected = editor.selected;
};
export default SceneComponent;

View File

@ -6,6 +6,7 @@ import LightComponent from '../../component/LightComponent';
import ShadowComponent from '../../component/ShadowComponent';
import GeometryComponent from '../../component/GeometryComponent';
import MaterialComponent from '../../component/MaterialComponent';
import SceneComponent from '../../component/SceneComponent';
/**
* 属性面板
@ -27,6 +28,7 @@ PropertyPanel.prototype.render = function () {
children: [
new BasicComponent({ app: this.app }),
new TransformComponent({ app: this.app }),
new SceneComponent({ app: this.app }),
new CameraComponent({ app: this.app }),
new LightComponent({ app: this.app }),
new ShadowComponent({ app: this.app }),