Replace BoxBrush with Brush in viewport-host.ts
This commit is contained in:
@@ -2376,7 +2376,7 @@ export class ViewportHost {
|
|||||||
size: {
|
size: {
|
||||||
...session.target.initialSize
|
...session.target.initialSize
|
||||||
},
|
},
|
||||||
geometry: cloneBoxBrushGeometry(session.target.initialGeometry)
|
geometry: cloneBrushGeometry(session.target.initialGeometry)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2482,7 +2482,7 @@ export class ViewportHost {
|
|||||||
size: {
|
size: {
|
||||||
...session.target.initialSize
|
...session.target.initialSize
|
||||||
},
|
},
|
||||||
geometry: cloneBoxBrushGeometry(session.target.initialGeometry)
|
geometry: cloneBrushGeometry(session.target.initialGeometry)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2688,7 +2688,7 @@ export class ViewportHost {
|
|||||||
...session.target.initialRotationDegrees
|
...session.target.initialRotationDegrees
|
||||||
},
|
},
|
||||||
size: nextSize,
|
size: nextSize,
|
||||||
geometry: scaleBoxBrushGeometryToSize(
|
geometry: scaleBrushGeometryToSize(
|
||||||
session.target.initialGeometry,
|
session.target.initialGeometry,
|
||||||
nextSize
|
nextSize
|
||||||
)
|
)
|
||||||
@@ -2750,7 +2750,7 @@ export class ViewportHost {
|
|||||||
|
|
||||||
private createTargetPreviewBrush(
|
private createTargetPreviewBrush(
|
||||||
session: ActiveTransformSession
|
session: ActiveTransformSession
|
||||||
): BoxBrush | null {
|
): Brush | null {
|
||||||
if (
|
if (
|
||||||
session.target.kind !== "brush" &&
|
session.target.kind !== "brush" &&
|
||||||
session.target.kind !== "brushFace" &&
|
session.target.kind !== "brushFace" &&
|
||||||
@@ -2762,12 +2762,11 @@ export class ViewportHost {
|
|||||||
|
|
||||||
const currentBrush = this.currentDocument?.brushes[session.target.brushId];
|
const currentBrush = this.currentDocument?.brushes[session.target.brushId];
|
||||||
|
|
||||||
if (currentBrush === undefined || currentBrush.kind !== "box") {
|
if (currentBrush === undefined) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return updateBrush(currentBrush, {
|
||||||
...currentBrush,
|
|
||||||
center: {
|
center: {
|
||||||
...session.target.initialCenter
|
...session.target.initialCenter
|
||||||
},
|
},
|
||||||
@@ -2777,21 +2776,21 @@ export class ViewportHost {
|
|||||||
size: {
|
size: {
|
||||||
...session.target.initialSize
|
...session.target.initialSize
|
||||||
},
|
},
|
||||||
geometry: cloneBoxBrushGeometry(session.target.initialGeometry)
|
geometry: cloneBrushGeometry(session.target.initialGeometry)
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private createBrushPreviewFromGeometry(
|
private createBrushPreviewFromGeometry(
|
||||||
brush: BoxBrush,
|
brush: Brush,
|
||||||
geometry: BoxBrushGeometry
|
geometry: BrushGeometry
|
||||||
): {
|
): {
|
||||||
kind: "brush";
|
kind: "brush";
|
||||||
center: Vec3;
|
center: Vec3;
|
||||||
rotationDegrees: Vec3;
|
rotationDegrees: Vec3;
|
||||||
size: Vec3;
|
size: Vec3;
|
||||||
geometry: BoxBrushGeometry;
|
geometry: BrushGeometry;
|
||||||
} {
|
} {
|
||||||
const nextGeometry = cloneBoxBrushGeometry(geometry);
|
const nextGeometry = cloneBrushGeometry(geometry);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
kind: "brush",
|
kind: "brush",
|
||||||
@@ -2801,19 +2800,30 @@ export class ViewportHost {
|
|||||||
rotationDegrees: {
|
rotationDegrees: {
|
||||||
...brush.rotationDegrees
|
...brush.rotationDegrees
|
||||||
},
|
},
|
||||||
size: deriveBoxBrushSizeFromGeometry(nextGeometry),
|
size: deriveBrushSizeFromGeometry(nextGeometry),
|
||||||
geometry: nextGeometry
|
geometry: nextGeometry
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private getComponentTargetVertexIds(
|
private getComponentTargetVertexIds(
|
||||||
target: ActiveTransformSession["target"]
|
target: ActiveTransformSession["target"]
|
||||||
): BoxVertexId[] {
|
): WhiteboxVertexId[] {
|
||||||
|
const brush = this.currentDocument?.brushes[target.brushId];
|
||||||
|
|
||||||
|
if (
|
||||||
|
brush === undefined ||
|
||||||
|
(target.kind !== "brushFace" &&
|
||||||
|
target.kind !== "brushEdge" &&
|
||||||
|
target.kind !== "brushVertex")
|
||||||
|
) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
switch (target.kind) {
|
switch (target.kind) {
|
||||||
case "brushFace":
|
case "brushFace":
|
||||||
return [...getBoxBrushFaceVertexIds(target.faceId)];
|
return [...getBrushFaceVertexIds(brush, target.faceId)];
|
||||||
case "brushEdge": {
|
case "brushEdge": {
|
||||||
const [start, end] = getBoxBrushEdgeVertexIds(target.edgeId);
|
const [start, end] = getBrushEdgeVertexIds(brush, target.edgeId);
|
||||||
return [start, end];
|
return [start, end];
|
||||||
}
|
}
|
||||||
case "brushVertex":
|
case "brushVertex":
|
||||||
@@ -2824,11 +2834,11 @@ export class ViewportHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private applyDeltaToVertices(
|
private applyDeltaToVertices(
|
||||||
brush: BoxBrush,
|
brush: Brush,
|
||||||
vertexIds: BoxVertexId[],
|
vertexIds: WhiteboxVertexId[],
|
||||||
delta: Vec3
|
delta: Vec3
|
||||||
): BoxBrushGeometry {
|
): BrushGeometry {
|
||||||
const nextGeometry = cloneBoxBrushGeometry(brush.geometry);
|
const nextGeometry = cloneBrushGeometry(brush.geometry);
|
||||||
|
|
||||||
for (const vertexId of vertexIds) {
|
for (const vertexId of vertexIds) {
|
||||||
const vertex = nextGeometry.vertices[vertexId];
|
const vertex = nextGeometry.vertices[vertexId];
|
||||||
|
|||||||
Reference in New Issue
Block a user