From 7352226989f4471704002b2407bc4435afabb286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Sun, 10 Nov 2024 18:09:22 +0100 Subject: [PATCH] due to numeric instability, Chrome was choosing the wrong orientation at the north pole, effectively putting the cubic map upside down. closes #75 --- src/cubic.js | 3 +-- src/polyhedral/voronoi.js | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cubic.js b/src/cubic.js index 82d6bb2..dc86c73 100644 --- a/src/cubic.js +++ b/src/cubic.js @@ -1,7 +1,7 @@ /* * Cubic map * - * Implemented for D3.js by Enrico Spinielli (2017) and Philippe Rivière (2017, 2018) + * Implemented for D3.js by Enrico Spinielli (2017) and Philippe Rivière (2017—2024) * */ import voronoi from "./polyhedral/voronoi.js"; @@ -38,7 +38,6 @@ export default function() { return voronoi() .polygons(polygons) .parents(parents) - .angle(0) .scale(96.8737) .center([135, -45]) .rotate([120,0]); diff --git a/src/polyhedral/voronoi.js b/src/polyhedral/voronoi.js index 11fa9e9..4ba7efd 100644 --- a/src/polyhedral/voronoi.js +++ b/src/polyhedral/voronoi.js @@ -12,7 +12,10 @@ import polyhedral from "./index.js"; const faceProjection0 = (face) => gnomonic() .scale(1) .translate([0, 0]) - .rotate([-face.site[0], -face.site[1]]); + .rotate([ + Math.abs(face.site[1]) > 89.99999999 ? 0 : -face.site[0], + -face.site[1] + ]); export default function( parents = [],