Skip to content

Commit

Permalink
Small refactor to use array.fill
Browse files Browse the repository at this point in the history
  • Loading branch information
vasturiano committed Nov 2, 2024
1 parent 0424a90 commit 490d917
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/layers/hexbin.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ export default Kapsule({
// update surfaceRadius per vertex
const vertexSurfaceRadius = GLOBE_RADIUS / (alt + 1);
obj.geometry.setAttribute('surfaceRadius', array2BufferAttr(
[...new Array(obj.geometry.getAttribute('position').count)].map(() => vertexSurfaceRadius), 1)
);
Array(obj.geometry.getAttribute('position').count).fill(vertexSurfaceRadius),
1
));
};

const currentTargetD = obj.__currentTargetD || Object.assign({}, targetD, { alt: -1e-3 });
Expand Down
2 changes: 1 addition & 1 deletion src/layers/points.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default Kapsule({
// color vertices
const color = color2ShaderArr(colorAccessor(d));
geom.setAttribute('color', array2BufferAttr(
[...new Array(geom.getAttribute('position').count)].map(() => color),
Array(geom.getAttribute('position').count).fill(color),
4
));

Expand Down
2 changes: 1 addition & 1 deletion src/utils/interpolate.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const THREE = window.THREE
export function interpolateVectors(fromPnts, toPnts) {
const extendArr = (arr, length) => {
const repeatItem = arr[arr.length-1];
return [...arr, ...[...new Array(length - arr.length)].map(() => repeatItem)];
return [...arr, ...Array(length - arr.length).fill(repeatItem)];
};

const arrLength = Math.max(fromPnts.length, toPnts.length);
Expand Down

0 comments on commit 490d917

Please sign in to comment.