From cdd8eed25649cfbaf262f85cef68a9735d8efbfa Mon Sep 17 00:00:00 2001 From: liteng <930372551@qq.com> Date: Thu, 18 Jul 2019 07:49:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=84=E7=A7=8DGeometry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../geometry/CircleGeometryComponent.jsx | 95 +++++++++++++++++++ .../geometry/CylinderGeometryComponent.jsx | 0 .../geometry/IcosahedronGeometryComponent.jsx | 0 .../geometry/LatheGeometryComponent.jsx | 0 .../geometry/PlaneGeometryComponent.jsx | 0 .../geometry/SphereGeometryComponent.jsx | 0 .../geometry/TeapotGeometryComponent.jsx | 0 .../geometry/TorusGeometryComponent.jsx | 0 .../geometry/TorusKnotGeometryComponent.jsx | 0 9 files changed, 95 insertions(+) create mode 100644 ShadowEditor.Web/src/editor2/component/geometry/CircleGeometryComponent.jsx create mode 100644 ShadowEditor.Web/src/editor2/component/geometry/CylinderGeometryComponent.jsx create mode 100644 ShadowEditor.Web/src/editor2/component/geometry/IcosahedronGeometryComponent.jsx create mode 100644 ShadowEditor.Web/src/editor2/component/geometry/LatheGeometryComponent.jsx create mode 100644 ShadowEditor.Web/src/editor2/component/geometry/PlaneGeometryComponent.jsx create mode 100644 ShadowEditor.Web/src/editor2/component/geometry/SphereGeometryComponent.jsx create mode 100644 ShadowEditor.Web/src/editor2/component/geometry/TeapotGeometryComponent.jsx create mode 100644 ShadowEditor.Web/src/editor2/component/geometry/TorusGeometryComponent.jsx create mode 100644 ShadowEditor.Web/src/editor2/component/geometry/TorusKnotGeometryComponent.jsx 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