auto-git:
[change] src/geometry/spline-road-mesh.ts
This commit is contained in:
@@ -512,6 +512,7 @@ export function buildSplineRoadEdgeMeshData(options: {
|
|||||||
path: SplineRoadPathLike;
|
path: SplineRoadPathLike;
|
||||||
side: ScenePathRoadEdgeSide;
|
side: ScenePathRoadEdgeSide;
|
||||||
terrains?: readonly Terrain[];
|
terrains?: readonly Terrain[];
|
||||||
|
clipIntervals?: readonly SplineCorridorPathClipInterval[];
|
||||||
}): SplineRoadEdgeMeshData | null {
|
}): SplineRoadEdgeMeshData | null {
|
||||||
const { path, side } = options;
|
const { path, side } = options;
|
||||||
const edge = path.road.edges[side];
|
const edge = path.road.edges[side];
|
||||||
@@ -542,10 +543,18 @@ export function buildSplineRoadEdgeMeshData(options: {
|
|||||||
const uvs: number[] = [];
|
const uvs: number[] = [];
|
||||||
const indices: number[] = [];
|
const indices: number[] = [];
|
||||||
const profileLastIndex = Math.max(1, profile.length - 1);
|
const profileLastIndex = Math.max(1, profile.length - 1);
|
||||||
|
const stationRuns = buildVisibleRoadStationRuns(
|
||||||
|
stations,
|
||||||
|
options.clipIntervals ?? []
|
||||||
|
);
|
||||||
|
let stationCount = 0;
|
||||||
|
|
||||||
for (let stationIndex = 0; stationIndex < stations.length; stationIndex += 1) {
|
for (const run of stationRuns) {
|
||||||
const station = stations[stationIndex]!;
|
const runVertexOffset = positions.length / 3;
|
||||||
const tangent = resolveStationTangent(stations, stationIndex);
|
|
||||||
|
for (let stationIndex = 0; stationIndex < run.length; stationIndex += 1) {
|
||||||
|
const station = run[stationIndex]!;
|
||||||
|
const tangent = resolveStationTangent(run, stationIndex);
|
||||||
|
|
||||||
if (tangent === null) {
|
if (tangent === null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -580,8 +589,8 @@ export function buildSplineRoadEdgeMeshData(options: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let stationIndex = 0; stationIndex < stations.length - 1; stationIndex += 1) {
|
for (let stationIndex = 0; stationIndex < run.length - 1; stationIndex += 1) {
|
||||||
const currentRow = stationIndex * profile.length;
|
const currentRow = runVertexOffset + stationIndex * profile.length;
|
||||||
const nextRow = currentRow + profile.length;
|
const nextRow = currentRow + profile.length;
|
||||||
|
|
||||||
for (let profileIndex = 0; profileIndex < profile.length - 1; profileIndex += 1) {
|
for (let profileIndex = 0; profileIndex < profile.length - 1; profileIndex += 1) {
|
||||||
@@ -598,17 +607,25 @@ export function buildSplineRoadEdgeMeshData(options: {
|
|||||||
addEdgeProfileCaps({
|
addEdgeProfileCaps({
|
||||||
indices,
|
indices,
|
||||||
profileVertexCount: profile.length,
|
profileVertexCount: profile.length,
|
||||||
stationCount: stations.length
|
vertexOffset: runVertexOffset,
|
||||||
|
stationCount: run.length
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stationCount += run.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (positions.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pathId: path.id,
|
pathId: path.id,
|
||||||
side,
|
side,
|
||||||
positions: new Float32Array(positions),
|
positions: new Float32Array(positions),
|
||||||
uvs: new Float32Array(uvs),
|
uvs: new Float32Array(uvs),
|
||||||
indices: new Uint32Array(indices),
|
indices: new Uint32Array(indices),
|
||||||
stationCount: stations.length,
|
stationCount,
|
||||||
totalLength: stations[stations.length - 1]?.distance ?? 0
|
totalLength: stations[stations.length - 1]?.distance ?? 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -617,6 +634,7 @@ export function buildSplineRoadEdgeMeshGeometry(options: {
|
|||||||
path: SplineRoadPathLike;
|
path: SplineRoadPathLike;
|
||||||
side: ScenePathRoadEdgeSide;
|
side: ScenePathRoadEdgeSide;
|
||||||
terrains?: readonly Terrain[];
|
terrains?: readonly Terrain[];
|
||||||
|
clipIntervals?: readonly SplineCorridorPathClipInterval[];
|
||||||
}): BufferGeometry | null {
|
}): BufferGeometry | null {
|
||||||
const meshData = buildSplineRoadEdgeMeshData(options);
|
const meshData = buildSplineRoadEdgeMeshData(options);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user