From 1235180f4dc1ab57a3d89fe12b2dda3adb00f495 Mon Sep 17 00:00:00 2001 From: ChenX Date: Tue, 6 Mar 2018 16:10:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0rotate=E5=91=BD=E4=BB=A4=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81ucs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/Rotate.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Add-on/Rotate.ts b/src/Add-on/Rotate.ts index f224f265e..f6966359a 100644 --- a/src/Add-on/Rotate.ts +++ b/src/Add-on/Rotate.ts @@ -3,6 +3,7 @@ import * as THREE from 'three'; import { app } from '../ApplicationServices/Application'; import { Command } from '../Editor/CommandMachine'; import { PromptStatus } from '../Editor/PromptResult'; +import { Matrix4 } from 'three'; export class Command_Rotate implements Command { @@ -20,12 +21,15 @@ export class Command_Rotate implements Command { return; } let pt1 = ptRes.Value; + let ucsInv = new Matrix4().getInverse(app.m_Editor.UCSMatrix); + let pt1Ucs = pt1.clone().applyMatrix4(ucsInv); app.m_Editor.m_CommandStore.Prompt("请输入第二个点:"); let an = 0; ptRes = await app.m_Editor.GetPoint({ Callback: (p: THREE.Vector3) => { - let rov = p.clone().sub(pt1); + let pInv = p.clone().applyMatrix4(ucsInv); + let rov = pInv.sub(pt1Ucs); let newan = Math.atan2(rov.y, rov.x); if (!newan) { @@ -38,7 +42,7 @@ export class Command_Rotate implements Command moveMatInv.getInverse(moveMat); let roMat = new THREE.Matrix4(); - roMat.makeRotationAxis(new THREE.Vector3(0, 0, 1), newan - an); + roMat.makeRotationAxis(new THREE.Vector3(0, 0, 1).applyMatrix4(app.m_Editor.UCSMatrix), newan - an); app.m_Viewer.m_OutlinePass.selectedObjects.forEach(o => { @@ -56,4 +60,4 @@ export class Command_Rotate implements Command } -} \ No newline at end of file +}