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