Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const margin = Math.max(0, Math.min(1, +marginAccessor(d)));
const color = colorAccessor(d);
const opacity = colorAlpha(color);
const material = new THREE.MeshLambertMaterial({
color,
transparent: opacity < 1,
opacity,
side: THREE.DoubleSide,
depthWrite: true
});
const h3Idxs = [];
if (geoJson.type === 'Polygon') {
h3Idxs.push(...polyfill(geoJson.coordinates, h3Res, true));
} else if (geoJson.type === 'MultiPolygon') {
geoJson.coordinates
.forEach(coords => h3Idxs.push(...polyfill(coords, h3Res, true)));
} else {
console.warn(`Unsupported GeoJson geometry type: ${geoJson.type}. Skipping geometry...`);
}
threeDigest(h3Idxs.map(h3Idx => ({ h3Idx })), obj, {
idAccessor: d => d.h3Idx,
createObj: ({ h3Idx }) => {
const obj = new THREE.Mesh();
obj.__hexCenter = h3ToGeo(h3Idx);
obj.__hexGeoJson = h3ToGeoBoundary(h3Idx, true);
// stitch longitudes at the anti-meridian
const centerLng = obj.__hexCenter[1];
.forEach(coords => h3Idxs.push(...polyfill(coords, h3Res, true)));
} else {
return flatten(polygons.map(polygon => h3.polyfill(polygon, resolution, true)));
}