From 89e22df7212f083fdc88258321039796c0d71913 Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming Date: Wed, 21 Aug 2024 16:30:52 +0200 Subject: [PATCH 1/2] Initial commit --- .../concrete/clipping/SliceDomainObject.ts | 4 ++-- .../concrete/primitives/line/LineView.ts | 8 +++++-- .../concrete/primitives/plane/PlaneCreator.ts | 23 ++++++++++++------- .../primitives/plane/PlaneRenderStyle.ts | 4 ++-- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/react-components/src/architecture/concrete/clipping/SliceDomainObject.ts b/react-components/src/architecture/concrete/clipping/SliceDomainObject.ts index 5560497a8d5..f8701aa82bc 100644 --- a/react-components/src/architecture/concrete/clipping/SliceDomainObject.ts +++ b/react-components/src/architecture/concrete/clipping/SliceDomainObject.ts @@ -21,8 +21,8 @@ export class SliceDomainObject extends PlaneDomainObject { public constructor(primitiveType: PrimitiveType) { super(primitiveType); - this.color = new Color(Color.NAMES.greenyellow); - this.backSideColor = new Color(Color.NAMES.red); + this.color = new Color(Color.NAMES.orangered); + this.backSideColor = new Color(Color.NAMES.palegreen); } // ================================================== diff --git a/react-components/src/architecture/concrete/primitives/line/LineView.ts b/react-components/src/architecture/concrete/primitives/line/LineView.ts index 4ba5677ab6e..209993d46f9 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineView.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineView.ts @@ -94,7 +94,7 @@ export class LineView extends GroupThreeView { return undefined; // Should never be picked } // Implement the intersection logic here, because of bug in tree.js - const radius = getRadius(domainObject, style); + const radius = getSelectRadius(domainObject, style); if (radius <= 0) { return; } @@ -108,7 +108,7 @@ export class LineView extends GroupThreeView { const thisPoint = new Vector3(); const intersection = new Vector3(); - const radiusSquared = square(1.5 * radius); // Add 50% more to make it easier to pick + const radiusSquared = square(radius); // Add more to make it easier to pick const ray = intersectInput.raycaster.ray; const closestFinder = new ClosestGeometryFinder(ray.origin); @@ -341,3 +341,7 @@ function adjustLabel( function getRadius(domainObject: LineDomainObject, style: LineRenderStyle): number { return domainObject.isSelected ? style.selectedPipeRadius : style.pipeRadius; } + +function getSelectRadius(domainObject: LineDomainObject, style: LineRenderStyle): number { + return 1.5 * style.selectedPipeRadius; +} diff --git a/react-components/src/architecture/concrete/primitives/plane/PlaneCreator.ts b/react-components/src/architecture/concrete/primitives/plane/PlaneCreator.ts index 515f224e886..39fb0b34f42 100644 --- a/react-components/src/architecture/concrete/primitives/plane/PlaneCreator.ts +++ b/react-components/src/architecture/concrete/primitives/plane/PlaneCreator.ts @@ -89,29 +89,36 @@ export class PlaneCreator extends BaseCreator { throw new Error('Cannot create a plane without points'); } const domainObject = this._domainObject; + let normal: Vector3; switch (domainObject.primitiveType) { case PrimitiveType.PlaneX: - domainObject.plane.setFromNormalAndCoplanarPoint(new Vector3(1, 0, 0), this.firstPoint); + normal = new Vector3(1, 0, 0); break; case PrimitiveType.PlaneY: - domainObject.plane.setFromNormalAndCoplanarPoint(new Vector3(0, 1, 0), this.firstPoint); + normal = new Vector3(0, 1, 0); break; case PrimitiveType.PlaneZ: - domainObject.plane.setFromNormalAndCoplanarPoint(new Vector3(0, 0, 1), this.firstPoint); + normal = new Vector3(0, 0, 1); break; case PrimitiveType.PlaneXY: if (this.pointCount === 1) { - const normal = ray.direction.clone().normalize(); - domainObject.plane.setFromNormalAndCoplanarPoint(normal, this.firstPoint); - } else if (this.pointCount === 2) { - const normal = new Vector3().subVectors(this.lastPoint, this.firstPoint).normalize(); + normal = ray.direction.clone().normalize(); + } else { + normal = new Vector3().subVectors(this.lastPoint, this.firstPoint).normalize(); rotatePiHalf(normal); - domainObject.plane.setFromNormalAndCoplanarPoint(normal, this.firstPoint); } break; + + default: + return; + } + // Make sure that the normal is pointing towards the camera + if (ray.direction.dot(normal) < 0) { + normal.negate(); } + domainObject.plane.setFromNormalAndCoplanarPoint(normal, this.firstPoint); } } diff --git a/react-components/src/architecture/concrete/primitives/plane/PlaneRenderStyle.ts b/react-components/src/architecture/concrete/primitives/plane/PlaneRenderStyle.ts index 0be0ff11cdc..baecfa626e9 100644 --- a/react-components/src/architecture/concrete/primitives/plane/PlaneRenderStyle.ts +++ b/react-components/src/architecture/concrete/primitives/plane/PlaneRenderStyle.ts @@ -17,8 +17,8 @@ export class PlaneRenderStyle extends CommonRenderStyle { public linesColor = BLACK_COLOR.clone(); public selectedLinesColor = WHITE_COLOR.clone(); public opacityUse = true; - public opacity = 0.5; - public selectedOpacity = 0.8; + public opacity = 0.25; + public selectedOpacity = 0.5; // ================================================== // OVERRIDES of BaseStyle From 024adee5507e5712cae93922257a994d0883589a Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming Date: Wed, 21 Aug 2024 16:36:30 +0200 Subject: [PATCH 2/2] Update LineView.ts --- .../src/architecture/concrete/primitives/line/LineView.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react-components/src/architecture/concrete/primitives/line/LineView.ts b/react-components/src/architecture/concrete/primitives/line/LineView.ts index 209993d46f9..830b67d17c0 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineView.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineView.ts @@ -108,7 +108,7 @@ export class LineView extends GroupThreeView { const thisPoint = new Vector3(); const intersection = new Vector3(); - const radiusSquared = square(radius); // Add more to make it easier to pick + const radiusSquared = square(radius); const ray = intersectInput.raycaster.ray; const closestFinder = new ClosestGeometryFinder(ray.origin); @@ -343,5 +343,5 @@ function getRadius(domainObject: LineDomainObject, style: LineRenderStyle): numb } function getSelectRadius(domainObject: LineDomainObject, style: LineRenderStyle): number { - return 1.5 * style.selectedPipeRadius; + return 1.5 * style.selectedPipeRadius; // Added more to make it easier to pick }