diff --git a/visualization/app/codeCharta/ui/codeMap/codeMap.label.service.spec.ts b/visualization/app/codeCharta/ui/codeMap/codeMap.label.service.spec.ts index 00141c18de..d44759e67e 100644 --- a/visualization/app/codeCharta/ui/codeMap/codeMap.label.service.spec.ts +++ b/visualization/app/codeCharta/ui/codeMap/codeMap.label.service.spec.ts @@ -155,7 +155,7 @@ describe("CodeMapLabelService", () => { it("scaling existing labels should scale their position correctly", () => { const SX = 1 const SY = 2 - const SZ = 1 + const SZ = 3 codeMapLabelService.addLabel(sampleLeaf, sampleSettings) codeMapLabelService.addLabel(sampleLeaf, sampleSettings) @@ -177,8 +177,12 @@ describe("CodeMapLabelService", () => { const scaleAfterA: Vector3 = codeMapLabelService["labels"][0].sprite.position const scaleAfterB: Vector3 = codeMapLabelService["labels"][1].sprite.position + expect(scaleAfterA.x).toBe((scaleBeforeA.x / 1) * SX) expect(scaleAfterA.y).toBe(((scaleBeforeA.y - 60) / 1) * SY + 60) + expect(scaleAfterA.z).toBe((scaleBeforeA.z / 1) * SZ) - expect(scaleAfterB.y).toBe(((scaleBeforeB.y - 60) / 1) * SY + 60) + expect(scaleAfterB.x).toBe((scaleBeforeA.x / 1) * SX) + expect(scaleAfterB.y).toBe(((scaleBeforeA.y - 60) / 1) * SY + 60) + expect(scaleAfterB.z).toBe((scaleBeforeA.z / 1) * SZ) }) }) diff --git a/visualization/app/codeCharta/ui/codeMap/codeMap.label.service.ts b/visualization/app/codeCharta/ui/codeMap/codeMap.label.service.ts index 7844f99cee..aea255b299 100644 --- a/visualization/app/codeCharta/ui/codeMap/codeMap.label.service.ts +++ b/visualization/app/codeCharta/ui/codeMap/codeMap.label.service.ts @@ -19,7 +19,7 @@ export class CodeMapLabelService implements CameraChangeSubscriber { private LABEL_WIDTH_DIVISOR: number = 2600 // empirically gathered private LABEL_HEIGHT_DIVISOR: number = 50 // empirically gathered - private currentHeightScale: number = 1 + private currentScale: Vector3 = new THREE.Vector3(1, 1, 1) private resetScale: boolean = false constructor( @@ -64,19 +64,26 @@ export class CodeMapLabelService implements CameraChangeSubscriber { public scale(scale: Vector3) { if (this.resetScale) { this.resetScale = false - this.currentHeightScale = 1 + this.currentScale = new THREE.Vector3(1, 1, 1) } for (let label of this.labels) { - label.sprite.position.y = ((label.sprite.position.y - 60) / this.currentHeightScale) * scale.y + 60 + label.sprite.position.x = (label.sprite.position.x / this.currentScale.x) * scale.x + label.sprite.position.y = ((label.sprite.position.y - 60) / this.currentScale.y) * scale.y + 60 + label.sprite.position.z = (label.sprite.position.z / this.currentScale.z) * scale.z //cast is a workaround for the compiler. Attribute vertices does exist on geometry //but it is missing in the mapping file for TypeScript. - ;(label.line!.geometry).vertices[0].y = ((label.line!.geometry).vertices[0].y / this.currentHeightScale) * scale.y + ;(label.line!.geometry).vertices[0].x = ((label.line!.geometry).vertices[0].x / this.currentScale.x) * scale.x + ;(label.line!.geometry).vertices[0].y = ((label.line!.geometry).vertices[0].y / this.currentScale.y) * scale.y + ;(label.line!.geometry).vertices[0].z = ((label.line!.geometry).vertices[0].z / this.currentScale.z) * scale.z + ;(label.line!.geometry).vertices[1].x = label.sprite.position.x ;(label.line!.geometry).vertices[1].y = label.sprite.position.y + ;(label.line!.geometry).vertices[1].z = label.sprite.position.z + label.line.geometry.translate(0, 0, 0) } - this.currentHeightScale = scale.y + this.currentScale.copy(scale) } public onCameraChanged(camera: PerspectiveCamera, event: angular.IAngularEvent) {