Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nilscognite committed Aug 21, 2024
1 parent a48739a commit 89e22df
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

// ==================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class LineView extends GroupThreeView<LineDomainObject> {
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;
}
Expand All @@ -108,7 +108,7 @@ export class LineView extends GroupThreeView<LineDomainObject> {
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<DomainObjectIntersection>(ray.origin);

Expand Down Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 89e22df

Please sign in to comment.