feat(workbench): expose junction geometry parameters
This commit is contained in:
1 parent
f6f51fe90b
commit
60e28f6b7a
2 files changed
+80
-13
No files matched your search
@@ -192,6 +192,21 @@ function App() {
|
||||
const segmentOf = (roadId: string) => state.compiled.model.roads.find((road) => road.id === roadId)?.segmentId;
|
||||
return handlesForSegment(manifest, selected?.segmentId ?? null, segmentOf);
|
||||
}, [editMode, manifest, selected, state]);
|
||||
// JunctionTools owns the three shape constraints for an ordinary node. Keep
|
||||
// the same manifest objects and callbacks as the main parameter panel so
|
||||
// number entry and dragging share one preview/undo protocol.
|
||||
const junctionHandles = useMemo(() => {
|
||||
if (!editMode || !junctionDescriptor || junctionDescriptor.ref.type !== 'node' || !manifest) return [];
|
||||
const nodeIds = new Set(junctionDescriptor.nodeIds.map(String));
|
||||
return manifest.handles.filter(
|
||||
(handle) =>
|
||||
(handle.kind === 'junction-approach-width' ||
|
||||
handle.kind === 'junction-cutback' ||
|
||||
handle.kind === 'junction-corner-radius') &&
|
||||
'nodeId' in handle.anchor &&
|
||||
nodeIds.has(String(handle.anchor.nodeId)),
|
||||
);
|
||||
}, [editMode, junctionDescriptor, manifest]);
|
||||
// A greyed handle without a reason reads as a bug rather than an ownership
|
||||
// boundary, so the first blocked handle explains itself in the header.
|
||||
const blockedHandle = editHandles.find((handle) => !handle.editable);
|
||||
@@ -700,6 +715,14 @@ function App() {
|
||||
(filter === 'candidates' ? Boolean(item.manualCandidates?.length) : !item.manualCandidates?.length)),
|
||||
);
|
||||
const openJunction = (ref: JunctionRef) => {
|
||||
// Seed direct-edit selection with the first approach so the existing
|
||||
// manifest request loads junction shape handles before the workspace opens.
|
||||
const descriptor = state ? hotspotAt(junctionDescriptors(state), ref) : null;
|
||||
const approach = descriptor?.approachRoadIds[0];
|
||||
if (approach) {
|
||||
const road = state?.compiled.model.roads.find((item) => item.id === approach);
|
||||
if (road) setSelected(road);
|
||||
}
|
||||
window.history.pushState({}, '', `/junction/${ref.type}/${encodeURIComponent(ref.id)}`);
|
||||
setJunctionRoute(ref);
|
||||
};
|
||||
@@ -855,8 +878,12 @@ function App() {
|
||||
visible={layers}
|
||||
scene={scene}
|
||||
junctionHotspots={junctionHotspots}
|
||||
onJunctionHotspot={(ref: JunctionRef) => {
|
||||
onJunctionHotspot={(ref: JunctionRef, _coordinate, descriptor) => {
|
||||
openJunction(ref);
|
||||
const approachRoad = descriptor.approachRoadIds
|
||||
.map((roadId) => state.compiled.model.roads.find((road) => road.id === roadId))
|
||||
.find((road): road is Road => Boolean(road));
|
||||
if (approachRoad) setSelected(approachRoad);
|
||||
setStatus(ref.type === 'node' ? `已定位路口节点 ${ref.id}(可编辑)` : `已定位路口 ${ref.id}(只读)`);
|
||||
}}
|
||||
onSelectRoad={setSelected}
|
||||
@@ -983,6 +1010,17 @@ function App() {
|
||||
setStatus((error as Error).message);
|
||||
}
|
||||
}}
|
||||
handles={junctionHandles}
|
||||
onDraft={draftValue}
|
||||
onSettle={(handle, value) => {
|
||||
settleValue(handle, value);
|
||||
setJunctionSession((current) => (current ? { ...current, status: 'draft', dirty: true } : current));
|
||||
}}
|
||||
onAbandon={abandonGesture}
|
||||
onReset={(handle) => {
|
||||
resetHandle(handle);
|
||||
setJunctionSession((current) => (current ? { ...current, status: 'draft', dirty: true } : current));
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
|
||||
Reference in new issue
Block a user