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