Revert "Bring constraints overlay in front of line labels; leave arrowheads when zooming out"

This reverts commit 251beb5fa6414d3b298d330e41d7ba3d57486f8c.
This commit is contained in:
49lf
2024-09-26 09:51:48 -04:00
parent f105044a47
commit 60d047ef6a
3 changed files with 7 additions and 50 deletions

View File

@ -233,9 +233,6 @@ const Overlay = ({
state.matches({ Sketch: 'Rectangle tool' }) state.matches({ Sketch: 'Rectangle tool' })
) )
// The constraint overlays need to go over the line labels.
const zIndex = 10
return ( return (
<div className={`absolute w-0 h-0`}> <div className={`absolute w-0 h-0`}>
<div <div
@ -246,7 +243,6 @@ const Overlay = ({
data-overlay-angle={overlay.angle} data-overlay-angle={overlay.angle}
className="pointer-events-auto absolute w-0 h-0" className="pointer-events-auto absolute w-0 h-0"
style={{ style={{
zIndex,
transform: `translate3d(${overlay.windowCoords[0]}px, ${overlay.windowCoords[1]}px, 0)`, transform: `translate3d(${overlay.windowCoords[0]}px, ${overlay.windowCoords[1]}px, 0)`,
}} }}
></div> ></div>
@ -255,7 +251,6 @@ const Overlay = ({
data-overlay-toolbar-index={overlayIndex} data-overlay-toolbar-index={overlayIndex}
className={`px-0 pointer-events-auto absolute flex gap-1`} className={`px-0 pointer-events-auto absolute flex gap-1`}
style={{ style={{
zIndex,
transform: `translate3d(calc(${ transform: `translate3d(calc(${
overlay.windowCoords[0] + xOffset overlay.windowCoords[0] + xOffset
}px + ${xAlignment}), calc(${ }px + ${xAlignment}), calc(${
@ -297,7 +292,6 @@ const Overlay = ({
*/} */}
{callExpression?.callee?.name !== 'circle' && ( {callExpression?.callee?.name !== 'circle' && (
<SegmentMenu <SegmentMenu
style={{ zIndex }}
verticalPosition={ verticalPosition={
overlay.windowCoords[1] > window.innerHeight / 2 overlay.windowCoords[1] > window.innerHeight / 2
? 'top' ? 'top'
@ -439,17 +433,15 @@ const SegmentMenu = ({
verticalPosition, verticalPosition,
pathToNode, pathToNode,
stdLibFnName, stdLibFnName,
style,
}: { }: {
verticalPosition: 'top' | 'bottom' verticalPosition: 'top' | 'bottom'
pathToNode: PathToNode pathToNode: PathToNode
stdLibFnName: string stdLibFnName: string
style?: CSSProperties
}) => { }) => {
const { send } = useModelingContext() const { send } = useModelingContext()
const dependentSourceRanges = findUsesOfTagInPipe(kclManager.ast, pathToNode) const dependentSourceRanges = findUsesOfTagInPipe(kclManager.ast, pathToNode)
return ( return (
<Popover className="relative" style={style}> <Popover className="relative">
{({ open }) => ( {({ open }) => (
<> <>
<Popover.Button <Popover.Button

View File

@ -52,7 +52,6 @@ export const Y_AXIS = 'yAxis'
export const AXIS_GROUP = 'axisGroup' export const AXIS_GROUP = 'axisGroup'
export const SKETCH_GROUP_SEGMENTS = 'sketch-group-segments' export const SKETCH_GROUP_SEGMENTS = 'sketch-group-segments'
export const ARROWHEAD = 'arrowhead' export const ARROWHEAD = 'arrowhead'
export const ADD_SEGMENT_DOT = 'add-segment-dot'
export const SEGMENT_LENGTH_LABEL = 'segment-length-label' export const SEGMENT_LENGTH_LABEL = 'segment-length-label'
export const SEGMENT_LENGTH_LABEL_TEXT = 'segment-length-label-text' export const SEGMENT_LENGTH_LABEL_TEXT = 'segment-length-label-text'
export const SEGMENT_LENGTH_LABEL_OFFSET_PX = 30 export const SEGMENT_LENGTH_LABEL_OFFSET_PX = 30

View File

@ -45,7 +45,6 @@ import {
import { getTangentPointFromPreviousArc } from 'lib/utils2d' import { getTangentPointFromPreviousArc } from 'lib/utils2d'
import { import {
ARROWHEAD, ARROWHEAD,
ADD_SEGMENT_DOT,
SceneInfra, SceneInfra,
SEGMENT_LENGTH_LABEL, SEGMENT_LENGTH_LABEL,
SEGMENT_LENGTH_LABEL_OFFSET_PX, SEGMENT_LENGTH_LABEL_OFFSET_PX,
@ -167,8 +166,6 @@ class StraightSegment implements SegmentUtils {
if (callExpName !== 'close') { if (callExpName !== 'close') {
// an arrowhead that appears at the end of the segment // an arrowhead that appears at the end of the segment
const arrowGroup = createArrowhead(scale, theme, color) const arrowGroup = createArrowhead(scale, theme, color)
const dotGroup = createAddNewSegmentDot(scale, theme, color)
// A length indicator that appears at the midpoint of the segment // A length indicator that appears at the midpoint of the segment
const lengthIndicatorGroup = createLengthIndicator({ const lengthIndicatorGroup = createLengthIndicator({
from, from,
@ -176,7 +173,6 @@ class StraightSegment implements SegmentUtils {
scale, scale,
}) })
segmentGroup.add(arrowGroup) segmentGroup.add(arrowGroup)
segmentGroup.add(dotGroup)
segmentGroup.add(lengthIndicatorGroup) segmentGroup.add(lengthIndicatorGroup)
} }
@ -211,7 +207,6 @@ class StraightSegment implements SegmentUtils {
shape.moveTo(0, (-SEGMENT_WIDTH_PX / 2) * scale) // The width of the line in px (2.4px in this case) shape.moveTo(0, (-SEGMENT_WIDTH_PX / 2) * scale) // The width of the line in px (2.4px in this case)
shape.lineTo(0, (SEGMENT_WIDTH_PX / 2) * scale) shape.lineTo(0, (SEGMENT_WIDTH_PX / 2) * scale)
const arrowGroup = group.getObjectByName(ARROWHEAD) as Group const arrowGroup = group.getObjectByName(ARROWHEAD) as Group
const dotGroup = group.getObjectByName(ADD_SEGMENT_DOT) as Group
const labelGroup = group.getObjectByName(SEGMENT_LENGTH_LABEL) as Group const labelGroup = group.getObjectByName(SEGMENT_LENGTH_LABEL) as Group
const length = Math.sqrt( const length = Math.sqrt(
@ -230,21 +225,9 @@ class StraightSegment implements SegmentUtils {
isHandlesVisible = !shouldHideHover isHandlesVisible = !shouldHideHover
} }
if (dotGroup) {
dotGroup.position.set(to[0], to[1], 0)
const dir = new Vector3()
.subVectors(
new Vector3(to[0], to[1], 0),
new Vector3(from[0], from[1], 0)
)
.normalize()
dotGroup.quaternion.setFromUnitVectors(new Vector3(0, 1, 0), dir)
dotGroup.scale.set(scale, scale, scale)
dotGroup.visible = isHandlesVisible
}
if (arrowGroup) { if (arrowGroup) {
arrowGroup.position.set(to[0], to[1], 0) arrowGroup.position.set(to[0], to[1], 0)
const dir = new Vector3() const dir = new Vector3()
.subVectors( .subVectors(
new Vector3(to[0], to[1], 0), new Vector3(to[0], to[1], 0),
@ -253,6 +236,7 @@ class StraightSegment implements SegmentUtils {
.normalize() .normalize()
arrowGroup.quaternion.setFromUnitVectors(new Vector3(0, 1, 0), dir) arrowGroup.quaternion.setFromUnitVectors(new Vector3(0, 1, 0), dir)
arrowGroup.scale.set(scale, scale, scale) arrowGroup.scale.set(scale, scale, scale)
arrowGroup.visible = isHandlesVisible
} }
const extraSegmentGroup = group.getObjectByName(EXTRA_SEGMENT_HANDLE) const extraSegmentGroup = group.getObjectByName(EXTRA_SEGMENT_HANDLE)
@ -357,7 +341,6 @@ class TangentialArcToSegment implements SegmentUtils {
const body = new MeshBasicMaterial({ color }) const body = new MeshBasicMaterial({ color })
const mesh = new Mesh(geometry, body) const mesh = new Mesh(geometry, body)
const arrowGroup = createArrowhead(scale, theme, color) const arrowGroup = createArrowhead(scale, theme, color)
const dotGroup = createAddNewSegmentDot(scale, theme, color)
const extraSegmentGroup = createExtraSegmentHandle(scale, texture, theme) const extraSegmentGroup = createExtraSegmentHandle(scale, texture, theme)
group.name = TANGENTIAL_ARC_TO_SEGMENT group.name = TANGENTIAL_ARC_TO_SEGMENT
@ -375,7 +358,7 @@ class TangentialArcToSegment implements SegmentUtils {
baseColor, baseColor,
} }
group.add(mesh, arrowGroup, dotGroup, extraSegmentGroup) group.add(mesh, arrowGroup, extraSegmentGroup)
const updateOverlaysCallback = this.update({ const updateOverlaysCallback = this.update({
prevSegment, prevSegment,
input, input,
@ -533,7 +516,6 @@ class CircleSegment implements SegmentUtils {
const arcMesh = new Mesh(geometry, mat) const arcMesh = new Mesh(geometry, mat)
const meshType = isDraftSegment ? CIRCLE_SEGMENT_DASH : CIRCLE_SEGMENT_BODY const meshType = isDraftSegment ? CIRCLE_SEGMENT_DASH : CIRCLE_SEGMENT_BODY
const arrowGroup = createArrowhead(scale, theme, color) const arrowGroup = createArrowhead(scale, theme, color)
const dotGroup = createAddNewSegmentDot(scale, theme, color)
const circleCenterGroup = createCircleCenterHandle(scale, theme, color) const circleCenterGroup = createCircleCenterHandle(scale, theme, color)
// A radius indicator that appears from the center to the perimeter // A radius indicator that appears from the center to the perimeter
const radiusIndicatorGroup = createLengthIndicator({ const radiusIndicatorGroup = createLengthIndicator({
@ -559,7 +541,7 @@ class CircleSegment implements SegmentUtils {
} }
group.name = CIRCLE_SEGMENT group.name = CIRCLE_SEGMENT
group.add(arcMesh, arrowGroup, dotGroup, circleCenterGroup) group.add(arcMesh, arrowGroup, circleCenterGroup)
const updateOverlaysCallback = this.update({ const updateOverlaysCallback = this.update({
prevSegment, prevSegment,
input, input,
@ -741,22 +723,6 @@ export function createProfileStartHandle({
return group return group
} }
function createAddNewSegmentDot(scale = 1, theme: Themes, color?: number): Group {
const baseColor = getThemeColorForThreeJs(theme)
const arrowMaterial = new MeshBasicMaterial({
color: color || baseColor,
})
const sphereMesh = new Mesh(new SphereGeometry(4, 12, 12), arrowMaterial)
const dotGroup = new Group()
dotGroup.userData.type = ADD_SEGMENT_DOT
dotGroup.name = ADD_SEGMENT_DOT
dotGroup.add(sphereMesh)
dotGroup.lookAt(new Vector3(0, 1, 0))
dotGroup.scale.set(scale, scale, scale)
return dotGroup
}
function createArrowhead(scale = 1, theme: Themes, color?: number): Group { function createArrowhead(scale = 1, theme: Themes, color?: number): Group {
const baseColor = getThemeColorForThreeJs(theme) const baseColor = getThemeColorForThreeJs(theme)
const arrowMaterial = new MeshBasicMaterial({ const arrowMaterial = new MeshBasicMaterial({
@ -766,16 +732,16 @@ function createArrowhead(scale = 1, theme: Themes, color?: number): Group {
// we'll scale the group to the correct size later to match these sizes in screen space // we'll scale the group to the correct size later to match these sizes in screen space
const arrowheadMesh = new Mesh(new ConeGeometry(4.5, 20, 12), arrowMaterial) const arrowheadMesh = new Mesh(new ConeGeometry(4.5, 20, 12), arrowMaterial)
arrowheadMesh.position.set(0, -9, 0) arrowheadMesh.position.set(0, -9, 0)
const sphereMesh = new Mesh(new SphereGeometry(4, 12, 12), arrowMaterial)
const arrowGroup = new Group() const arrowGroup = new Group()
arrowGroup.userData.type = ARROWHEAD arrowGroup.userData.type = ARROWHEAD
arrowGroup.name = ARROWHEAD arrowGroup.name = ARROWHEAD
arrowGroup.add(arrowheadMesh) arrowGroup.add(arrowheadMesh, sphereMesh)
arrowGroup.lookAt(new Vector3(0, 1, 0)) arrowGroup.lookAt(new Vector3(0, 1, 0))
arrowGroup.scale.set(scale, scale, scale) arrowGroup.scale.set(scale, scale, scale)
return arrowGroup return arrowGroup
} }
function createCircleCenterHandle( function createCircleCenterHandle(
scale = 1, scale = 1,
theme: Themes, theme: Themes,