mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
场景组件。
This commit is contained in:
parent
6fa2e9e2f6
commit
c8acc22140
69
ShadowEditor.Web/src/component/SceneComponent.js
Normal file
69
ShadowEditor.Web/src/component/SceneComponent.js
Normal 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;
|
||||
@ -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 }),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user