From f8a46aa5ef67da321d2a799570dcba7463dd071f Mon Sep 17 00:00:00 2001 From: liteng <930372551@qq.com> Date: Sat, 29 Sep 2018 07:58:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9C=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShadowEditor.Web/src/editor/menubar/AddMenu.js | 14 ++------------ ShadowEditor.Web/src/object/geometry/Circle.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 ShadowEditor.Web/src/object/geometry/Circle.js diff --git a/ShadowEditor.Web/src/editor/menubar/AddMenu.js b/ShadowEditor.Web/src/editor/menubar/AddMenu.js index c047fa2d..66a5c25a 100644 --- a/ShadowEditor.Web/src/editor/menubar/AddMenu.js +++ b/ShadowEditor.Web/src/editor/menubar/AddMenu.js @@ -4,6 +4,7 @@ import StringUtils from '../../utils/StringUtils'; import Plane from '../../object/geometry/Plane'; import Box from '../../object/geometry/Box'; +import Circle from '../../object/geometry/Circle'; import PointLight from '../../object/light/PointLight'; import HemisphereLight from '../../object/light/HemisphereLight'; @@ -167,18 +168,7 @@ AddMenu.prototype.addBox = function () { // ------------------------ 圆 ---------------------------------- AddMenu.prototype.addCircle = function () { - var editor = this.app.editor; - - var radius = 1; - var segments = 32; - - var geometry = new THREE.CircleBufferGeometry(radius, segments); - var mesh = new THREE.Mesh(geometry, new THREE.MeshStandardMaterial()); - mesh.name = '圆'; - mesh.castShadow = true; - mesh.receiveShadow = true; - - editor.execute(new AddObjectCommand(mesh)); + this.app.editor.execute(new AddObjectCommand(new Circle())); }; // ------------------------圆柱体 ------------------------------- diff --git a/ShadowEditor.Web/src/object/geometry/Circle.js b/ShadowEditor.Web/src/object/geometry/Circle.js new file mode 100644 index 00000000..4951855a --- /dev/null +++ b/ShadowEditor.Web/src/object/geometry/Circle.js @@ -0,0 +1,17 @@ +/** + * 圆 + * @param {*} geometry 几何体 + * @param {*} material 材质 + */ +function Circle(geometry = new THREE.CircleBufferGeometry(1, 32), material = new THREE.MeshStandardMaterial()) { + THREE.Mesh.call(this, geometry, material); + + this.name = '圆'; + this.castShadow = true; + this.receiveShadow = true; +} + +Circle.prototype = Object.create(THREE.Mesh.prototype); +Circle.prototype.constructor = Circle; + +export default Circle; \ No newline at end of file