Add shape mode support (straight, curve, corner) to spline corridor junctions
This commit is contained in:
@@ -9,6 +9,7 @@ export type SplineCorridorJunctionTerrainMode =
|
||||
| "none"
|
||||
| "paintOnly"
|
||||
| "flattenAndPaint";
|
||||
export type SplineCorridorJunctionShapeMode = "straight" | "curve" | "corner";
|
||||
|
||||
export interface SplineCorridorJunctionConnection {
|
||||
id: string;
|
||||
@@ -27,6 +28,7 @@ export interface SplineCorridorJunction {
|
||||
radius: number;
|
||||
materialId: string | null;
|
||||
terrainMode: SplineCorridorJunctionTerrainMode;
|
||||
shapeMode: SplineCorridorJunctionShapeMode;
|
||||
edge: ScenePathRoadEdgeSettings;
|
||||
connections: SplineCorridorJunctionConnection[];
|
||||
}
|
||||
@@ -43,6 +45,8 @@ export const DEFAULT_SPLINE_CORRIDOR_JUNCTION_CLIP_DISTANCE = 1.5;
|
||||
export const DEFAULT_SPLINE_CORRIDOR_JUNCTION_MATERIAL_ID = null;
|
||||
export const DEFAULT_SPLINE_CORRIDOR_JUNCTION_TERRAIN_MODE: SplineCorridorJunctionTerrainMode =
|
||||
"flattenAndPaint";
|
||||
export const DEFAULT_SPLINE_CORRIDOR_JUNCTION_SHAPE_MODE: SplineCorridorJunctionShapeMode =
|
||||
"straight";
|
||||
export const DEFAULT_SPLINE_CORRIDOR_JUNCTION_EDGE_ENABLED = false;
|
||||
export const MIN_SPLINE_CORRIDOR_JUNCTION_RADIUS = 0.05;
|
||||
export const MAX_SPLINE_CORRIDOR_JUNCTION_RADIUS = 500;
|
||||
@@ -53,6 +57,11 @@ export const SPLINE_CORRIDOR_JUNCTION_TERRAIN_MODES = [
|
||||
"paintOnly",
|
||||
"flattenAndPaint"
|
||||
] as const satisfies readonly SplineCorridorJunctionTerrainMode[];
|
||||
export const SPLINE_CORRIDOR_JUNCTION_SHAPE_MODES = [
|
||||
"straight",
|
||||
"curve",
|
||||
"corner"
|
||||
] as const satisfies readonly SplineCorridorJunctionShapeMode[];
|
||||
|
||||
function cloneVec3(vector: Vec3): Vec3 {
|
||||
return {
|
||||
@@ -87,6 +96,14 @@ export function isSplineCorridorJunctionTerrainMode(
|
||||
);
|
||||
}
|
||||
|
||||
export function isSplineCorridorJunctionShapeMode(
|
||||
value: unknown
|
||||
): value is SplineCorridorJunctionShapeMode {
|
||||
return SPLINE_CORRIDOR_JUNCTION_SHAPE_MODES.includes(
|
||||
value as SplineCorridorJunctionShapeMode
|
||||
);
|
||||
}
|
||||
|
||||
export function normalizeSplineCorridorJunctionRadius(value: number): number {
|
||||
return normalizePositiveFiniteNumber(
|
||||
value,
|
||||
@@ -141,6 +158,18 @@ export function normalizeSplineCorridorJunctionTerrainMode(
|
||||
);
|
||||
}
|
||||
|
||||
export function normalizeSplineCorridorJunctionShapeMode(
|
||||
value: unknown
|
||||
): SplineCorridorJunctionShapeMode {
|
||||
if (isSplineCorridorJunctionShapeMode(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Spline corridor junction shape mode must be straight, curve, or corner."
|
||||
);
|
||||
}
|
||||
|
||||
export function createSplineCorridorJunctionConnection(
|
||||
overrides: Partial<SplineCorridorJunctionConnection> & {
|
||||
pathId: string;
|
||||
@@ -196,6 +225,10 @@ export function createSplineCorridorJunction(
|
||||
overrides.terrainMode === undefined
|
||||
? DEFAULT_SPLINE_CORRIDOR_JUNCTION_TERRAIN_MODE
|
||||
: normalizeSplineCorridorJunctionTerrainMode(overrides.terrainMode),
|
||||
shapeMode:
|
||||
overrides.shapeMode === undefined
|
||||
? DEFAULT_SPLINE_CORRIDOR_JUNCTION_SHAPE_MODE
|
||||
: normalizeSplineCorridorJunctionShapeMode(overrides.shapeMode),
|
||||
edge: createScenePathRoadEdgeSettings({
|
||||
enabled:
|
||||
overrides.edge?.enabled ?? DEFAULT_SPLINE_CORRIDOR_JUNCTION_EDGE_ENABLED,
|
||||
|
||||
Reference in New Issue
Block a user