artifact map clean up (PART 2.1) (#3130)
* variable renaming * fix fillet
This commit is contained in:
@ -1566,16 +1566,16 @@ export class SceneEntities {
|
||||
// If we clicked on an extrude wall, we climb up the parent Id
|
||||
// to get the sketch profile's face ID. If we clicked on an endcap,
|
||||
// we already have it.
|
||||
const targetId =
|
||||
const pathId =
|
||||
artifact?.type === 'extrudeWall' || artifact?.type === 'extrudeCap'
|
||||
? artifact.segmentId
|
||||
? artifact.pathId
|
||||
: ''
|
||||
|
||||
// tsc cannot infer that target can have extrusions
|
||||
// from the commandType (why?) so we need to cast it
|
||||
const target = this.engineCommandManager.artifactMap?.[targetId || '']
|
||||
const path = this.engineCommandManager.artifactMap?.[pathId || '']
|
||||
const extrusionId =
|
||||
target?.type === 'startPath' ? target.extrusions[0] : ''
|
||||
path?.type === 'startPath' ? path.extrusionIds[0] : ''
|
||||
|
||||
// TODO: We get the first extrusion command ID,
|
||||
// which is fine while backend systems only support one extrusion.
|
||||
@ -1609,10 +1609,7 @@ export class SceneEntities {
|
||||
) as [number, number, number],
|
||||
sketchPathToNode,
|
||||
extrudePathToNode,
|
||||
cap:
|
||||
artifact.type === 'extrudeCap'
|
||||
? artifact.additionalData.info
|
||||
: 'none',
|
||||
cap: artifact.type === 'extrudeCap' ? artifact.cap : 'none',
|
||||
faceId: _entity_id,
|
||||
},
|
||||
})
|
||||
|
@ -9,12 +9,12 @@ interface CommonCommandProperties {
|
||||
|
||||
interface ExtrudeArtifact extends CommonCommandProperties {
|
||||
type: 'extrude'
|
||||
target: string
|
||||
pathId: string
|
||||
}
|
||||
|
||||
export interface StartPathArtifact extends CommonCommandProperties {
|
||||
type: 'startPath'
|
||||
extrusions: string[]
|
||||
extrusionIds: string[]
|
||||
}
|
||||
|
||||
export interface SegmentArtifact extends CommonCommandProperties {
|
||||
@ -25,15 +25,12 @@ export interface SegmentArtifact extends CommonCommandProperties {
|
||||
|
||||
interface ExtrudeCapArtifact extends CommonCommandProperties {
|
||||
type: 'extrudeCap'
|
||||
additionalData: {
|
||||
type: 'cap'
|
||||
info: 'start' | 'end'
|
||||
}
|
||||
segmentId: string
|
||||
cap: 'start' | 'end'
|
||||
pathId: string
|
||||
}
|
||||
interface ExtrudeWallArtifact extends CommonCommandProperties {
|
||||
type: 'extrudeWall'
|
||||
segmentId: string
|
||||
pathId: string
|
||||
}
|
||||
|
||||
interface PatternInstance extends CommonCommandProperties {
|
||||
@ -154,7 +151,7 @@ function handleIndividualResponse({
|
||||
type: 'extrude',
|
||||
range,
|
||||
pathToNode,
|
||||
target: command2.target,
|
||||
pathId: command2.target,
|
||||
},
|
||||
})
|
||||
|
||||
@ -167,8 +164,8 @@ function handleIndividualResponse({
|
||||
type: 'startPath',
|
||||
range: targetArtifact.range,
|
||||
pathToNode: targetArtifact.pathToNode,
|
||||
extrusions: targetArtifact?.extrusions
|
||||
? [...targetArtifact?.extrusions, id]
|
||||
extrusionIds: targetArtifact?.extrusionIds
|
||||
? [...targetArtifact?.extrusionIds, id]
|
||||
: [id],
|
||||
},
|
||||
})
|
||||
@ -204,7 +201,7 @@ function handleIndividualResponse({
|
||||
type: 'startPath',
|
||||
range,
|
||||
pathToNode,
|
||||
extrusions: [],
|
||||
extrusionIds: [],
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -247,15 +244,11 @@ function handleIndividualResponse({
|
||||
artifacts.push({
|
||||
commandId: face.face_id,
|
||||
artifact: {
|
||||
// ...parent,
|
||||
type: 'extrudeCap',
|
||||
additionalData: {
|
||||
type: 'cap',
|
||||
info: face.cap === 'bottom' ? 'start' : 'end',
|
||||
},
|
||||
cap: face.cap === 'bottom' ? 'start' : 'end',
|
||||
range: parent.range,
|
||||
pathToNode: parent.pathToNode,
|
||||
segmentId:
|
||||
pathId:
|
||||
edgeArtifact?.type === 'segment' ? edgeArtifact.pathId : '',
|
||||
},
|
||||
})
|
||||
@ -265,11 +258,10 @@ function handleIndividualResponse({
|
||||
artifacts.push({
|
||||
commandId: face.face_id,
|
||||
artifact: {
|
||||
...curveArtifact,
|
||||
type: 'extrudeWall',
|
||||
range: curveArtifact.range,
|
||||
pathToNode: curveArtifact.pathToNode,
|
||||
segmentId: curveArtifact.pathId,
|
||||
pathId: curveArtifact.pathId,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -115,10 +115,7 @@ export async function getEventForSelectWithPoint(
|
||||
selectionType: 'singleCodeCursor',
|
||||
selection: {
|
||||
range: sourceRange,
|
||||
type:
|
||||
_artifact?.additionalData.info === 'end'
|
||||
? 'end-cap'
|
||||
: 'start-cap',
|
||||
type: _artifact?.cap === 'end' ? 'end-cap' : 'start-cap',
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -525,7 +522,7 @@ function codeToIdSelections(
|
||||
if (
|
||||
type === 'start-cap' &&
|
||||
entry.artifact.type === 'extrudeCap' &&
|
||||
entry?.artifact?.additionalData?.info === 'start'
|
||||
entry?.artifact?.cap === 'start'
|
||||
) {
|
||||
bestCandidate = entry
|
||||
return
|
||||
@ -533,7 +530,7 @@ function codeToIdSelections(
|
||||
if (
|
||||
type === 'end-cap' &&
|
||||
entry.artifact.type === 'extrudeCap' &&
|
||||
entry?.artifact?.additionalData?.info === 'end'
|
||||
entry?.artifact?.cap === 'end'
|
||||
) {
|
||||
bestCandidate = entry
|
||||
return
|
||||
|
@ -1143,11 +1143,10 @@ export const modelingMachine = createMachine(
|
||||
if (sketchGroup?.type !== 'SketchGroup') return
|
||||
const idArtifact = engineCommandManager.artifactMap[sketchGroup.id]
|
||||
if (idArtifact.type !== 'startPath') return
|
||||
const extrusionArtifactId = (idArtifact as any)?.extrusions?.[0]
|
||||
const extrusionArtifactId = idArtifact?.extrusionIds?.[0]
|
||||
if (typeof extrusionArtifactId !== 'string') return
|
||||
const extrusionArtifact = (engineCommandManager.artifactMap as any)[
|
||||
extrusionArtifactId
|
||||
]
|
||||
const extrusionArtifact =
|
||||
engineCommandManager.artifactMap[extrusionArtifactId]
|
||||
if (!extrusionArtifact) return
|
||||
const pathToExtrudeNode = getNodePathFromSourceRange(
|
||||
ast,
|
||||
|
Reference in New Issue
Block a user