make close segment visually distinct (#1620)
This commit is contained in:
@ -135,8 +135,8 @@ test('Basic sketch', async ({ page }) => {
|
|||||||
|> angledLine([180, segLen('seg01', %)], %)`)
|
|> angledLine([180, segLen('seg01', %)], %)`)
|
||||||
})
|
})
|
||||||
|
|
||||||
test.skip(process.platform === 'darwin', 'Can moving camera')
|
|
||||||
test('Can moving camera', async ({ page, context }) => {
|
test('Can moving camera', async ({ page, context }) => {
|
||||||
|
test.skip(process.platform === 'darwin', 'Can moving camera')
|
||||||
const u = getUtils(page)
|
const u = getUtils(page)
|
||||||
await page.setViewportSize({ width: 1200, height: 500 })
|
await page.setViewportSize({ width: 1200, height: 500 })
|
||||||
await page.goto('/')
|
await page.goto('/')
|
||||||
|
@ -342,6 +342,11 @@ class SceneEntities {
|
|||||||
const isDraftSegment =
|
const isDraftSegment =
|
||||||
draftSegment && index === sketchGroup.value.length - 1
|
draftSegment && index === sketchGroup.value.length - 1
|
||||||
let seg
|
let seg
|
||||||
|
const callExpName = getNodeFromPath<CallExpression>(
|
||||||
|
kclManager.ast,
|
||||||
|
segPathToNode,
|
||||||
|
'CallExpression'
|
||||||
|
)?.node?.callee?.name
|
||||||
if (segment.type === 'TangentialArcTo') {
|
if (segment.type === 'TangentialArcTo') {
|
||||||
seg = tangentialArcToSegment({
|
seg = tangentialArcToSegment({
|
||||||
prevSegment: sketchGroup.value[index - 1],
|
prevSegment: sketchGroup.value[index - 1],
|
||||||
@ -360,6 +365,7 @@ class SceneEntities {
|
|||||||
pathToNode: segPathToNode,
|
pathToNode: segPathToNode,
|
||||||
isDraftSegment,
|
isDraftSegment,
|
||||||
scale: factor,
|
scale: factor,
|
||||||
|
callExpName,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
seg.layers.set(SKETCH_LAYER)
|
seg.layers.set(SKETCH_LAYER)
|
||||||
@ -739,6 +745,7 @@ class SceneEntities {
|
|||||||
shape.lineTo(0, 0.08 * scale) // The width of the line
|
shape.lineTo(0, 0.08 * scale) // The width of the line
|
||||||
const arrowGroup = group.getObjectByName(ARROWHEAD) as Group
|
const arrowGroup = group.getObjectByName(ARROWHEAD) as Group
|
||||||
|
|
||||||
|
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()
|
||||||
@ -749,6 +756,7 @@ class SceneEntities {
|
|||||||
.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)
|
||||||
|
}
|
||||||
|
|
||||||
const straightSegmentBody = group.children.find(
|
const straightSegmentBody = group.children.find(
|
||||||
(child) => child.userData.type === STRAIGHT_SEGMENT_BODY
|
(child) => child.userData.type === STRAIGHT_SEGMENT_BODY
|
||||||
@ -1117,7 +1125,10 @@ function mouseEnterLeaveCallbacks() {
|
|||||||
PROFILE_START,
|
PROFILE_START,
|
||||||
])
|
])
|
||||||
const isSelected = parent?.userData?.isSelected
|
const isSelected = parent?.userData?.isSelected
|
||||||
colorSegment(selected, isSelected ? 0x0000ff : 0xffffff)
|
colorSegment(
|
||||||
|
selected,
|
||||||
|
isSelected ? 0x0000ff : parent?.userData?.baseColor || 0xffffff
|
||||||
|
)
|
||||||
if ([X_AXIS, Y_AXIS].includes(selected?.userData?.type)) {
|
if ([X_AXIS, Y_AXIS].includes(selected?.userData?.type)) {
|
||||||
const obj = selected as Mesh
|
const obj = selected as Mesh
|
||||||
const mat = obj.material as MeshBasicMaterial
|
const mat = obj.material as MeshBasicMaterial
|
||||||
|
@ -70,6 +70,7 @@ export function straightSegment({
|
|||||||
pathToNode,
|
pathToNode,
|
||||||
isDraftSegment,
|
isDraftSegment,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
|
callExpName,
|
||||||
}: {
|
}: {
|
||||||
from: Coords2d
|
from: Coords2d
|
||||||
to: Coords2d
|
to: Coords2d
|
||||||
@ -77,6 +78,7 @@ export function straightSegment({
|
|||||||
pathToNode: PathToNode
|
pathToNode: PathToNode
|
||||||
isDraftSegment?: boolean
|
isDraftSegment?: boolean
|
||||||
scale?: number
|
scale?: number
|
||||||
|
callExpName: string
|
||||||
}): Group {
|
}): Group {
|
||||||
const group = new Group()
|
const group = new Group()
|
||||||
|
|
||||||
@ -100,7 +102,8 @@ export function straightSegment({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const body = new MeshBasicMaterial({ color: 0xffffff })
|
const baseColor = callExpName === 'close' ? 0x444444 : 0xffffff
|
||||||
|
const body = new MeshBasicMaterial({ color: baseColor })
|
||||||
const mesh = new Mesh(geometry, body)
|
const mesh = new Mesh(geometry, body)
|
||||||
mesh.userData.type = isDraftSegment
|
mesh.userData.type = isDraftSegment
|
||||||
? STRAIGHT_SEGMENT_DASH
|
? STRAIGHT_SEGMENT_DASH
|
||||||
@ -114,6 +117,8 @@ export function straightSegment({
|
|||||||
to,
|
to,
|
||||||
pathToNode,
|
pathToNode,
|
||||||
isSelected: false,
|
isSelected: false,
|
||||||
|
callExpName,
|
||||||
|
baseColor,
|
||||||
}
|
}
|
||||||
group.name = STRAIGHT_SEGMENT
|
group.name = STRAIGHT_SEGMENT
|
||||||
|
|
||||||
@ -124,7 +129,8 @@ export function straightSegment({
|
|||||||
.normalize()
|
.normalize()
|
||||||
arrowGroup.quaternion.setFromUnitVectors(new Vector3(0, 1, 0), dir)
|
arrowGroup.quaternion.setFromUnitVectors(new Vector3(0, 1, 0), dir)
|
||||||
|
|
||||||
group.add(mesh, arrowGroup)
|
group.add(mesh)
|
||||||
|
if (callExpName !== 'close') group.add(arrowGroup)
|
||||||
|
|
||||||
return group
|
return group
|
||||||
}
|
}
|
||||||
|
@ -425,7 +425,9 @@ function updateSceneObjectColors(codeBasedSelections: Selection[]) {
|
|||||||
const groupHasCursor = codeBasedSelections.some((selection) => {
|
const groupHasCursor = codeBasedSelections.some((selection) => {
|
||||||
return isOverlap(selection.range, [node.start, node.end])
|
return isOverlap(selection.range, [node.start, node.end])
|
||||||
})
|
})
|
||||||
const color = groupHasCursor ? 0x0000ff : 0xffffff
|
const color = groupHasCursor
|
||||||
|
? 0x0000ff
|
||||||
|
: segmentGroup?.userData?.baseColor || 0xffffff
|
||||||
segmentGroup.traverse(
|
segmentGroup.traverse(
|
||||||
(child) => child instanceof Mesh && child.material.color.set(color)
|
(child) => child instanceof Mesh && child.material.color.set(color)
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user