Enhance junction footprint creation to support detailed connection parameters (path ID, distance, side, and outward axis).
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
|||||||
sampleResolvedScenePathPosition,
|
sampleResolvedScenePathPosition,
|
||||||
sampleResolvedScenePathTangent,
|
sampleResolvedScenePathTangent,
|
||||||
type ScenePathCurveMode,
|
type ScenePathCurveMode,
|
||||||
|
type ScenePathRoadEdgeSide,
|
||||||
type ScenePathPoint,
|
type ScenePathPoint,
|
||||||
type ScenePathRoadSettings
|
type ScenePathRoadSettings
|
||||||
} from "../document/paths";
|
} from "../document/paths";
|
||||||
@@ -31,6 +32,10 @@ export interface SplineCorridorJunctionFootprintPoint {
|
|||||||
fallbackY: number;
|
fallbackY: number;
|
||||||
heightOffset: number;
|
heightOffset: number;
|
||||||
connectionBoundaryKey: string | null;
|
connectionBoundaryKey: string | null;
|
||||||
|
connectionPathId?: string;
|
||||||
|
connectionDistance?: number;
|
||||||
|
connectionSide?: ScenePathRoadEdgeSide;
|
||||||
|
connectionOutwardAxis?: { x: number; z: number };
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SplineCorridorJunctionFootprint {
|
export interface SplineCorridorJunctionFootprint {
|
||||||
@@ -109,13 +114,21 @@ function createFootprintPoint(options: {
|
|||||||
offset: number;
|
offset: number;
|
||||||
heightOffset: number;
|
heightOffset: number;
|
||||||
connectionBoundaryKey: string;
|
connectionBoundaryKey: string;
|
||||||
|
connectionPathId: string;
|
||||||
|
connectionDistance: number;
|
||||||
|
connectionSide: ScenePathRoadEdgeSide;
|
||||||
|
connectionOutwardAxis: { x: number; z: number };
|
||||||
}): SplineCorridorJunctionFootprintPoint {
|
}): SplineCorridorJunctionFootprintPoint {
|
||||||
return {
|
return {
|
||||||
x: options.position.x + options.leftAxis.x * options.offset,
|
x: options.position.x + options.leftAxis.x * options.offset,
|
||||||
z: options.position.z + options.leftAxis.z * options.offset,
|
z: options.position.z + options.leftAxis.z * options.offset,
|
||||||
fallbackY: options.position.y + options.heightOffset,
|
fallbackY: options.position.y + options.heightOffset,
|
||||||
heightOffset: options.heightOffset,
|
heightOffset: options.heightOffset,
|
||||||
connectionBoundaryKey: options.connectionBoundaryKey
|
connectionBoundaryKey: options.connectionBoundaryKey,
|
||||||
|
connectionPathId: options.connectionPathId,
|
||||||
|
connectionDistance: options.connectionDistance,
|
||||||
|
connectionSide: options.connectionSide,
|
||||||
|
connectionOutwardAxis: options.connectionOutwardAxis
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,14 +218,25 @@ function addConnectionBoundaryPoints(options: {
|
|||||||
leftAxis: localLeftAxis,
|
leftAxis: localLeftAxis,
|
||||||
offset: halfWidth,
|
offset: halfWidth,
|
||||||
heightOffset,
|
heightOffset,
|
||||||
connectionBoundaryKey
|
connectionBoundaryKey,
|
||||||
|
connectionPathId: options.path.id,
|
||||||
|
connectionDistance: distance,
|
||||||
|
connectionSide: "left",
|
||||||
|
connectionOutwardAxis: localLeftAxis
|
||||||
}),
|
}),
|
||||||
createFootprintPoint({
|
createFootprintPoint({
|
||||||
position,
|
position,
|
||||||
leftAxis: localLeftAxis,
|
leftAxis: localLeftAxis,
|
||||||
offset: -halfWidth,
|
offset: -halfWidth,
|
||||||
heightOffset,
|
heightOffset,
|
||||||
connectionBoundaryKey
|
connectionBoundaryKey,
|
||||||
|
connectionPathId: options.path.id,
|
||||||
|
connectionDistance: distance,
|
||||||
|
connectionSide: "right",
|
||||||
|
connectionOutwardAxis: {
|
||||||
|
x: -localLeftAxis.x,
|
||||||
|
z: -localLeftAxis.z
|
||||||
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -252,10 +276,18 @@ function dedupePoints(
|
|||||||
|
|
||||||
existing.fallbackY = (existing.fallbackY + point.fallbackY) * 0.5;
|
existing.fallbackY = (existing.fallbackY + point.fallbackY) * 0.5;
|
||||||
existing.heightOffset = (existing.heightOffset + point.heightOffset) * 0.5;
|
existing.heightOffset = (existing.heightOffset + point.heightOffset) * 0.5;
|
||||||
existing.connectionBoundaryKey =
|
const keepsConnection =
|
||||||
existing.connectionBoundaryKey === point.connectionBoundaryKey
|
existing.connectionBoundaryKey === point.connectionBoundaryKey &&
|
||||||
? existing.connectionBoundaryKey
|
existing.connectionPathId === point.connectionPathId &&
|
||||||
: null;
|
existing.connectionSide === point.connectionSide;
|
||||||
|
|
||||||
|
if (!keepsConnection) {
|
||||||
|
existing.connectionBoundaryKey = null;
|
||||||
|
delete existing.connectionPathId;
|
||||||
|
delete existing.connectionDistance;
|
||||||
|
delete existing.connectionSide;
|
||||||
|
delete existing.connectionOutwardAxis;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return deduped;
|
return deduped;
|
||||||
|
|||||||
Reference in New Issue
Block a user