Fix a winding order bug in viewport clipping.
Introduced by bfce5d5d11
(<= vs <).
This commit is contained in:
Родитель
ceee009ae1
Коммит
657effbeea
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "d3",
|
||||
"version": "3.4.0",
|
||||
"version": "3.4.1",
|
||||
"main": "d3.js",
|
||||
"scripts": [
|
||||
"d3.js"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"animation",
|
||||
"canvas"
|
||||
],
|
||||
"version": "3.4.0",
|
||||
"version": "3.4.1",
|
||||
"main": "d3.js",
|
||||
"scripts": [
|
||||
"d3.js"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
!function() {
|
||||
var d3 = {
|
||||
version: "3.4.0"
|
||||
version: "3.4.1"
|
||||
};
|
||||
if (!Date.now) Date.now = function() {
|
||||
return +new Date();
|
||||
|
@ -1179,11 +1179,8 @@
|
|||
function d3_sgn(x) {
|
||||
return x > 0 ? 1 : x < 0 ? -1 : 0;
|
||||
}
|
||||
function d3_isCCWTurn(a, b, c) {
|
||||
return d3_cross2d(a, b, c) > 0;
|
||||
}
|
||||
function d3_cross2d(o, a, b) {
|
||||
return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
|
||||
function d3_cross2d(a, b, c) {
|
||||
return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
|
||||
}
|
||||
function d3_acos(x) {
|
||||
return x > 1 ? 0 : x < -1 ? π : Math.acos(x);
|
||||
|
@ -3633,9 +3630,9 @@
|
|||
for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) {
|
||||
b = v[j];
|
||||
if (a[1] <= y) {
|
||||
if (b[1] > y && d3_isCCWTurn(a, b, p)) ++wn;
|
||||
if (b[1] > y && d3_cross2d(a, b, p) > 0) ++wn;
|
||||
} else {
|
||||
if (b[1] <= y && !d3_isCCWTurn(a, b, p)) --wn;
|
||||
if (b[1] <= y && d3_cross2d(a, b, p) < 0) --wn;
|
||||
}
|
||||
a = b;
|
||||
}
|
||||
|
@ -4733,9 +4730,7 @@
|
|||
function d3_geom_hullUpper(points) {
|
||||
var n = points.length, hull = [ 0, 1 ], hs = 2;
|
||||
for (var i = 2; i < n; i++) {
|
||||
while (hs > 1 && !d3_isCCWTurn(points[hull[hs - 2]], points[hull[hs - 1]], points[i])) {
|
||||
hs--;
|
||||
}
|
||||
while (hs > 1 && d3_cross2d(points[hull[hs - 2]], points[hull[hs - 1]], points[i]) <= 0) --hs;
|
||||
hull[hs++] = i;
|
||||
}
|
||||
return hull.slice(0, hs);
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "d3",
|
||||
"version": "3.4.0",
|
||||
"version": "3.4.1",
|
||||
"description": "A small, free JavaScript library for manipulating documents based on data.",
|
||||
"keywords": [
|
||||
"dom",
|
||||
|
|
|
@ -79,9 +79,9 @@ function d3_geo_clipExtent(x0, y0, x1, y1) {
|
|||
for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) {
|
||||
b = v[j];
|
||||
if (a[1] <= y) {
|
||||
if (b[1] > y && d3_isCCWTurn(a, b, p)) ++wn;
|
||||
if (b[1] > y && d3_cross2d(a, b, p) > 0) ++wn;
|
||||
} else {
|
||||
if (b[1] <= y && !d3_isCCWTurn(a, b, p)) --wn;
|
||||
if (b[1] <= y && d3_cross2d(a, b, p) < 0) --wn;
|
||||
}
|
||||
a = b;
|
||||
}
|
||||
|
|
|
@ -49,10 +49,10 @@ d3.geom.hull = function(vertices) {
|
|||
skipRight = lower[lower.length - 1] === upper[upper.length - 1],
|
||||
polygon = [];
|
||||
|
||||
for (i = upper.length - 1; i >= 0; --i)
|
||||
polygon.push(data[points[upper[i]][2]]); // add upper hull in r->l order
|
||||
for (i = +skipLeft; i < lower.length - skipRight; ++i)
|
||||
polygon.push(data[points[lower[i]][2]]); // add lower hull in l->r order
|
||||
// add upper hull in r->l order
|
||||
// then add lower hull in l->r order
|
||||
for (i = upper.length - 1; i >= 0; --i) polygon.push(data[points[upper[i]][2]]);
|
||||
for (i = +skipLeft; i < lower.length - skipRight; ++i) polygon.push(data[points[lower[i]][2]]);
|
||||
|
||||
return polygon;
|
||||
}
|
||||
|
@ -77,14 +77,15 @@ function d3_geom_hullUpper(points) {
|
|||
hs = 2; // hull size
|
||||
|
||||
for (var i = 2; i < n; i++) {
|
||||
while (hs > 1 && !d3_isCCWTurn(points[hull[hs-2]], points[hull[hs-1]], points[i])) {
|
||||
hs --;
|
||||
}
|
||||
while (hs > 1 && d3_cross2d(points[hull[hs-2]], points[hull[hs-1]], points[i]) <= 0) --hs;
|
||||
hull[hs++] = i;
|
||||
}
|
||||
|
||||
// we slice to make sure that the points we 'popped' from hull don't stay behind
|
||||
return hull.slice(0, hs);
|
||||
}
|
||||
|
||||
// comparator for ascending sort by x-coord first, y-coord second
|
||||
function d3_geom_hullOrder(a, b) { return a[0] - b[0] || a[1] - b[1]; }
|
||||
function d3_geom_hullOrder(a, b) {
|
||||
return a[0] - b[0] || a[1] - b[1];
|
||||
}
|
||||
|
|
|
@ -10,20 +10,12 @@ function d3_sgn(x) {
|
|||
return x > 0 ? 1 : x < 0 ? -1 : 0;
|
||||
}
|
||||
|
||||
// returns true iff the [x,y] points a, b, c form a counter-clockwise turn in
|
||||
// the traditional Cartesian coordinate system (i.e. x value grows from left
|
||||
// to right, y value grows from bottom to top)
|
||||
function d3_isCCWTurn(a, b, c) {
|
||||
return d3_cross2d(a, b, c) > 0;
|
||||
}
|
||||
|
||||
// 2D cross product of OA and OB vectors, i.e. z-component of their 3D cross
|
||||
// product, in traditional Cartesian coordinate system (x value grows from
|
||||
// left to right, y value grows from bottom to top). Returns a positive value
|
||||
// if OAB makes a counter-clockwise turn, negative for clockwise turn, and
|
||||
// zero if the points are collinear.
|
||||
function d3_cross2d(o, a, b) {
|
||||
return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
|
||||
// Returns the 2D cross product of AB and AC vectors, i.e., the z-component of
|
||||
// the 3D cross product in a quadrant I Cartesian coordinate system (+x is
|
||||
// right, +y is up). Returns a positive value if ABC is counter-clockwise,
|
||||
// negative if clockwise, and zero if the points are collinear.
|
||||
function d3_cross2d(a, b, c) {
|
||||
return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
|
||||
}
|
||||
|
||||
function d3_acos(x) {
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
!function(){
|
||||
var d3 = {version: "3.4.0"}; // semver
|
||||
var d3 = {version: "3.4.1"}; // semver
|
||||
|
|
Загрузка…
Ссылка в новой задаче