diff --git a/src/uitls/RotationObject.ts b/src/uitls/RotationObject.ts index beca6bb6f1298ada31570d47234bc2e2cc25e48b..3d11ee04600475b4616d7286d33ce472e541ca4a 100644 --- a/src/uitls/RotationObject.ts +++ b/src/uitls/RotationObject.ts @@ -13,7 +13,7 @@ export class RotationObject implements Updatable, Modifiable { public t: number = 0; private _qworking: Quaternion = new Quaternion();; - private _orientation: Group = new Group(); + // private _orientation: Group = new Group(); private _coordinate: Group = new Group(); private _rotationAxis: Group = new Group(); private _mesh?: Mesh; @@ -159,43 +159,53 @@ export class RotationObject implements Updatable, Modifiable { } updateRotationAxis(): void { - const line = this._rotationAxis.getObjectByName("rotationAxisLine") as Line; - const point = this._rotationAxis.getObjectByName("rotationAxisPoint") as Mesh; - if (line.geometry) - line.geometry.dispose(); + const suffix: string[] = ["A", "B", "C"]; + const ref: Quaternion[] = [this.qa, this.qb, this._qworking]; - const dir = new Vector3( - this._qworking.x, - this._qworking.y, - this._qworking.z - ); - const origin = new Vector3(0, 0, 0); + for (let i = 0; i < suffix.length; i++) { + const line = this._rotationAxis.getObjectByName("rotationAxisLine" + suffix[i]) as Line; + const point = this._rotationAxis.getObjectByName("rotationAxisPoint" + suffix[i]) as Mesh; - line.geometry = new BufferGeometry().setFromPoints([ - origin, dir.normalize()]); + if (line.geometry) line.geometry.dispose(); - point.position.copy(dir); + const dir = new Vector3( + ref[i].x, + ref[i].y, + ref[i].z + ) + const origin = new Vector3(0,0,0); + + line.geometry = new BufferGeometry().setFromPoints([origin, dir.normalize().multiplyScalar(2)]); + point.position.copy(dir); + } } createRotationAxis(): void { - const dir = new Line( - undefined, - new LineBasicMaterial({ color: 0xff8844 }) - ); - dir.name = "rotationAxisLine"; + const colors: Color[] = [ + new Color(0xff8844), + new Color(0x44ff88), + new Color(0x884488) + ] + const suffix: string[] = ["A", "B", "C"]; - const point = new Mesh( - new SphereBufferGeometry(.025, 32, 32), - new MeshBasicMaterial({ color: 0xff8844 }) - ); - point.name = "rotationAxisPoint"; + for (let i = 0; i < suffix.length; i++) { + const line = new Line( + undefined, + new LineBasicMaterial({ color: colors[i].getHex() }) + ); + line.name = "rotationAxisLine" + suffix[i]; + this._rotationAxis.add(line); - this._rotationAxis.add(dir); - this._rotationAxis.add(point); + const point = new Mesh( + new SphereBufferGeometry(.05, 32, 32), + new MeshBasicMaterial({ color: colors[i].getHex() }) + ); + point.name = "rotationAxisPoint" + suffix[i]; + this._rotationAxis.add(point); + } this.updateRotationAxis(); - } setMesh(mesh: Mesh): void {