fix(line-layer): 修复相邻线段重叠情况下的接头处理

This commit is contained in:
xiaoiver 2019-06-17 16:55:18 +08:00
parent a9d2c276d7
commit d4a8f2943e
1 changed files with 22 additions and 1 deletions

View File

@ -88,7 +88,28 @@ export default function(points, closed, indexOffset) {
// get orientation
let flip = (dot(tangent, _normal) < 0) ? -1 : 1;
const bevel = miterLen > miterLimit;
const bevel = Math.abs(miterLen) > miterLimit;
// 处理前后两条线段重合的情况这种情况不需要使用任何接头miter/bevel
// 理论上这种情况下 miterLen = Infinity本应通过 isFinite(miterLen) 判断,
// 但是 AMap 投影变换后丢失精度只能通过一个阈值1000判断。
if (Math.abs(miterLen) > 1000) {
normal(_normal, lineA);
extrusions(attrPos, out, cur, _normal, 1);
attrDistance.push(d, d);
attrIndex.push(
_lastFlip === 1 ? [ index + 1, index + 3, index + 2 ]
: [ index, index + 2, index + 3 ]
);
// 避免在 Material 中使用 THREE.DoubleSide
attrIndex.push([ index + 2, index + 3, index + 4 ]);
count += 2;
_lastFlip = -1;
continue;
}
if (bevel) {
miterLen = miterLimit;