diff --git a/ShadowEditor.Web/src/editor2/component/geometry/CircleGeometryComponent.jsx b/ShadowEditor.Web/src/editor2/component/geometry/CircleGeometryComponent.jsx new file mode 100644 index 00000000..a53f53e6 --- /dev/null +++ b/ShadowEditor.Web/src/editor2/component/geometry/CircleGeometryComponent.jsx @@ -0,0 +1,95 @@ +import { PropertyGrid, PropertyGroup, TextProperty, DisplayProperty, CheckBoxProperty, NumberProperty, IntegerProperty } from '../../../third_party'; +import SetGeometryCommand from '../../../command/SetGeometryCommand'; + +/** + * 正方体组件 + * @author tengge / https://github.com/tengge1 + */ +class CircleGeometryComponent extends React.Component { + constructor(props) { + super(props); + + this.selected = null; + + this.state = { + show: false, + expanded: true, + width: 1, + height: 1, + depth: 1, + widthSegments: 1, + heightSegments: 1, + depthSegments: 1, + }; + + this.handleExpand = this.handleExpand.bind(this); + this.handleUpdate = this.handleUpdate.bind(this); + this.handleChange = this.handleChange.bind(this); + } + + render() { + const { show, expanded, width, height, depth, widthSegments, heightSegments, depthSegments } = this.state; + + if (!show) { + return null; + } + + return + + + + + + + ; + } + + componentDidMount() { + app.on(`objectSelected.BoxGeometryComponent`, this.handleUpdate); + app.on(`objectChanged.BoxGeometryComponent`, this.handleUpdate); + } + + handleExpand(expanded) { + this.setState({ + expanded, + }); + } + + handleUpdate() { + const editor = app.editor; + + if (!editor.selected || !(editor.selected instanceof THREE.Mesh) || !(editor.selected.geometry instanceof THREE.BoxBufferGeometry)) { + this.setState({ + show: false, + }); + return; + } + + this.selected = editor.selected; + + const state = Object.assign({}, this.selected.geometry.parameters, { + show: true, + }); + + this.setState(state); + } + + handleChange(value, name, event) { + const state = Object.assign({}, this.state, { + [name]: value, + }); + + this.setState(state); + + app.editor.execute(new SetGeometryCommand(this.selected, new THREE.BoxBufferGeometry( + state.width, + state.height, + state.depth, + state.widthSegments, + state.heightSegments, + state.depthSegments, + ))); + } +} + +export default CircleGeometryComponent; \ No newline at end of file diff --git a/ShadowEditor.Web/src/editor2/component/geometry/CylinderGeometryComponent.jsx b/ShadowEditor.Web/src/editor2/component/geometry/CylinderGeometryComponent.jsx new file mode 100644 index 00000000..e69de29b diff --git a/ShadowEditor.Web/src/editor2/component/geometry/IcosahedronGeometryComponent.jsx b/ShadowEditor.Web/src/editor2/component/geometry/IcosahedronGeometryComponent.jsx new file mode 100644 index 00000000..e69de29b diff --git a/ShadowEditor.Web/src/editor2/component/geometry/LatheGeometryComponent.jsx b/ShadowEditor.Web/src/editor2/component/geometry/LatheGeometryComponent.jsx new file mode 100644 index 00000000..e69de29b diff --git a/ShadowEditor.Web/src/editor2/component/geometry/PlaneGeometryComponent.jsx b/ShadowEditor.Web/src/editor2/component/geometry/PlaneGeometryComponent.jsx new file mode 100644 index 00000000..e69de29b diff --git a/ShadowEditor.Web/src/editor2/component/geometry/SphereGeometryComponent.jsx b/ShadowEditor.Web/src/editor2/component/geometry/SphereGeometryComponent.jsx new file mode 100644 index 00000000..e69de29b diff --git a/ShadowEditor.Web/src/editor2/component/geometry/TeapotGeometryComponent.jsx b/ShadowEditor.Web/src/editor2/component/geometry/TeapotGeometryComponent.jsx new file mode 100644 index 00000000..e69de29b diff --git a/ShadowEditor.Web/src/editor2/component/geometry/TorusGeometryComponent.jsx b/ShadowEditor.Web/src/editor2/component/geometry/TorusGeometryComponent.jsx new file mode 100644 index 00000000..e69de29b diff --git a/ShadowEditor.Web/src/editor2/component/geometry/TorusKnotGeometryComponent.jsx b/ShadowEditor.Web/src/editor2/component/geometry/TorusKnotGeometryComponent.jsx new file mode 100644 index 00000000..e69de29b