From d8edc47a421ec2d2740d612f2bcbfbf7415c91de Mon Sep 17 00:00:00 2001 From: liteng <930372551@qq.com> Date: Thu, 14 Feb 2019 20:57:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B2=E7=BA=BF=E4=BF=AE=E6=94=B9=EF=BC=8C?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E5=B8=AE=E5=8A=A9=E5=99=A8=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/helper/line/SplineHelper.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ShadowEditor.Web/src/helper/line/SplineHelper.js b/ShadowEditor.Web/src/helper/line/SplineHelper.js index 72ea7905..a57c9646 100644 --- a/ShadowEditor.Web/src/helper/line/SplineHelper.js +++ b/ShadowEditor.Web/src/helper/line/SplineHelper.js @@ -36,17 +36,25 @@ SplineHelper.prototype.onObjectSelected = function (object) { }; SplineHelper.prototype.onObjectChanged = function (obj) { - if (!obj.userData || !(obj.userData.type === 'helper')) { + if (this.box.length === 0) { return; } - var object = obj.userData.object; + var line = this.box[0].userData.object; - var index = this.box.indexOf(obj); + if (obj === line) { // 修改了线 + this.box.forEach((n, i) => { + n.position.copy(line.position).add(line.userData.points[i]); + }); + } else if (obj.userData && obj.userData.type === 'helper') { // 修改了帮助器 + var object = obj.userData.object; - if (index > -1) { - object.userData.points[index].copy(object.position).multiplyScalar(-1).add(obj.position); - object.update(); + var index = this.box.indexOf(obj); + + if (index > -1) { + object.userData.points[index].copy(object.position).multiplyScalar(-1).add(obj.position); + object.update(); + } } }; @@ -55,7 +63,7 @@ SplineHelper.prototype.onSelectLine = function (object) { this.onCancelSelectLine(); - var geometry = new THREE.BoxBufferGeometry(1, 1, 1); + var geometry = new THREE.BoxBufferGeometry(0.4, 0.4, 0.4); var material = new THREE.MeshBasicMaterial({ color: 0xff0000 }); @@ -63,7 +71,7 @@ SplineHelper.prototype.onSelectLine = function (object) { object.userData.points.forEach(n => { var mesh = new THREE.Mesh(geometry, material); - mesh.position.copy(n); + mesh.position.copy(object.position).add(n); Object.assign(mesh.userData, { type: 'helper',