Skip to content

Commit

Permalink
Fix #49. Prevent buffer geometry mem leak in tiles and hex polygons data
Browse files Browse the repository at this point in the history
  • Loading branch information
vasturiano committed Feb 28, 2022
1 parent 638f4fa commit 87c301b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/layers/hexedPolygons.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export default Kapsule({
const applyUpdate = td => {
const { alt, margin, curvatureResolution } = obj.__currentTargetD = td;

obj.geometry && obj.geometry.dispose();
obj.geometry = !hexBins.length
? new THREE.BufferGeometry()
: BufferGeometryUtils.mergeBufferGeometries(hexBins.map(h => {
Expand Down
1 change: 1 addition & 0 deletions src/layers/tiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default Kapsule({
const rotLng = deg2Rad(lng);
const rotLat = deg2Rad(-lat);

obj.geometry && obj.geometry.dispose();
obj.geometry = new THREE.SphereBufferGeometry(
GLOBE_RADIUS * (1 + alt),
Math.ceil(width / (curvatureResolution || -1)),
Expand Down

0 comments on commit 87c301b

Please sign in to comment.