|
|
|
@ -73,7 +73,6 @@ export class SweepBufferGeometry extends BufferGeometry
|
|
|
|
|
needVers.push(...ProjectionToPlane(shapePts, path.Normal, pathPts[i], pathPts[i - 1], pathPts[i + 1]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let alluv: Vector2[] = [];
|
|
|
|
|
const f4 = (a, b, c, d) =>
|
|
|
|
|
{
|
|
|
|
|
verticesArray.push(...needVers[a].toArray());
|
|
|
|
@ -83,14 +82,6 @@ export class SweepBufferGeometry extends BufferGeometry
|
|
|
|
|
verticesArray.push(...needVers[b].toArray());
|
|
|
|
|
verticesArray.push(...needVers[d].toArray());
|
|
|
|
|
verticesArray.push(...needVers[c].toArray());
|
|
|
|
|
|
|
|
|
|
uvs.push(...alluv[a].toArray());
|
|
|
|
|
uvs.push(...alluv[b].toArray());
|
|
|
|
|
uvs.push(...alluv[c].toArray());
|
|
|
|
|
|
|
|
|
|
uvs.push(...alluv[b].toArray());
|
|
|
|
|
uvs.push(...alluv[d].toArray());
|
|
|
|
|
uvs.push(...alluv[c].toArray());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//盖子,顶面底面.
|
|
|
|
@ -126,10 +117,6 @@ export class SweepBufferGeometry extends BufferGeometry
|
|
|
|
|
{
|
|
|
|
|
uvYs.push((uvYs[i - 1] + shapePts[i].distanceTo(shapePts[i - 1]) * 1e-3) % 1);
|
|
|
|
|
}
|
|
|
|
|
uvYs.forEach(y =>
|
|
|
|
|
{
|
|
|
|
|
alluv.push(new Vector2(0, y));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let x = 0;
|
|
|
|
|
//侧面
|
|
|
|
@ -140,18 +127,32 @@ export class SweepBufferGeometry extends BufferGeometry
|
|
|
|
|
let c0 = count * (i - 1);
|
|
|
|
|
let c1 = count * i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let pBase = needVers[c0];//基点.
|
|
|
|
|
let pathVec = pathPts[i].clone().sub(pathPts[i - 1]).normalize();//路径前进方向
|
|
|
|
|
let sideUvs = [];
|
|
|
|
|
for (let j = 0; j < count; j++)
|
|
|
|
|
{
|
|
|
|
|
let c0j = c0 + j;
|
|
|
|
|
let c1j = c1 + j;
|
|
|
|
|
|
|
|
|
|
let newx = alluv[c0j].x + needVers[c1j].distanceTo(needVers[c0j]) * 1e-3;
|
|
|
|
|
alluv.push(new Vector2(newx, uvYs[j]));
|
|
|
|
|
let x1 = needVers[c0j].clone().sub(pBase).dot(pathVec) * 1e-3;
|
|
|
|
|
let x2 = needVers[c1j].clone().sub(pBase).dot(pathVec) * 1e-3;
|
|
|
|
|
sideUvs.push(new Vector2(x1, uvYs[j]));
|
|
|
|
|
sideUvs.push(new Vector2(x2, uvYs[j]));
|
|
|
|
|
}
|
|
|
|
|
for (let j = 0; j < count; j++)
|
|
|
|
|
{
|
|
|
|
|
let jn = FixIndex(j + 1, count);
|
|
|
|
|
f4(c0 + j, c0 + jn, c1 + j, c1 + jn);
|
|
|
|
|
|
|
|
|
|
uvs.push(...sideUvs[j * 2].toArray());//a
|
|
|
|
|
uvs.push(...sideUvs[jn * 2].toArray());//b
|
|
|
|
|
uvs.push(...sideUvs[j * 2 + 1].toArray());//c
|
|
|
|
|
|
|
|
|
|
uvs.push(...sideUvs[jn * 2].toArray());//b
|
|
|
|
|
uvs.push(...sideUvs[jn * 2 + 1].toArray());//d
|
|
|
|
|
uvs.push(...sideUvs[j * 2 + 1].toArray());//c
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|