Skip to content

Commit

Permalink
Update CylinderView.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
nilscognite committed Feb 19, 2025
1 parent 9c203cd commit 18cb75c
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { Wireframe } from 'three/examples/jsm/lines/Wireframe.js';
import { clear } from '../../../base/utilities/extensions/arrayExtensions';
import { Quantity } from '../../../base/domainObjectsHelpers/Quantity';
import { PrimitiveType } from '../../../base/utilities/primitives/PrimitiveType';
import { getRoot } from '../../../base/domainObjects/getRoot';

const RELATIVE_RESIZE_RADIUS = 0.2;
const RELATIVE_MAX_RADIUS = 0.9;
Expand Down Expand Up @@ -293,11 +294,8 @@ export class CylinderView extends GroupThreeView<CylinderDomainObject> {
}

private addLabels(matrix: Matrix4): void {
const { domainObject, style } = this;
const { rootDomainObject } = domainObject;
if (rootDomainObject === undefined) {
return undefined;
}
const { style } = this;

const spriteHeight = this.getTextHeight(style.relativeTextSize);
clear(this._sprites);
this.addChild(this.createRadiusLabel(matrix, spriteHeight, TOP_FACE));
Expand All @@ -316,14 +314,14 @@ export class CylinderView extends GroupThreeView<CylinderDomainObject> {
return undefined;
}
const { domainObject } = this;
const { rootDomainObject } = domainObject;
if (rootDomainObject === undefined) {
return undefined;
}
const radius = domainObject.cylinder.radius;
if (radius === 0) {
return undefined; // Not show when about 0
}
const rootDomainObject = getRoot(domainObject);
if (rootDomainObject === undefined) {
return undefined;
}
const text = rootDomainObject.unitSystem.toStringWithUnit(radius, Quantity.Length);
const sprite = BoxView.createSprite(text, this.style, spriteHeight);
if (sprite === undefined) {
Expand Down

0 comments on commit 18cb75c

Please sign in to comment.