Skip to content

Commit 6bb60f4

Browse files
committed
fix(example): Fix destroy gui when we change source dataset on pointcloud examples
1 parent f531af6 commit 6bb60f4

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

examples/pointcloud_loader.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@
6060
<div id="viewerDiv"></div>
6161

6262
<script type="module">
63-
import { Vector3 } from 'three';
6463
import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
6564
import Stats from 'stats-gl';
6665
import { getFormat, getPointCloudClass, getDefaultAttribute, zoomToLayer } from './jsm/PointCloudHelper.js';
6766

68-
import { CRS, MAIN_LOOP_EVENTS, PNTS_MODE, PlanarControls, View } from 'itowns';
67+
import { CRS, MAIN_LOOP_EVENTS, PlanarControls, View } from 'itowns';
6968
import { PointCloudDebug } from 'debug';
7069

7170
const viewerDiv = document.getElementById('viewerDiv');
@@ -87,6 +86,7 @@
8786
window.updateUrlParams = updateUrlParams;
8887

8988
let currentView = null;
89+
let gui = null;
9090

9191
window.load = async function load(url, options = {}) {
9292
// Cleanup previous view
@@ -96,6 +96,10 @@
9696
viewerDiv.innerHTML = '';
9797
}
9898

99+
if (gui) {
100+
gui.destroy();
101+
}
102+
99103
const { format = 'auto', crs } = options;
100104
const { Source, Layer } = getPointCloudClass(format);
101105

@@ -131,7 +135,7 @@
131135
const controls = new PlanarControls(view);
132136
controls.groundLevel = layer.minElevationRange;
133137

134-
const gui = new GUI();
138+
gui = new GUI();
135139
PointCloudDebug.initTools(view, layer, gui);
136140
}
137141

examples/pointcloud_loader_globe.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,12 @@
6060
<div id="viewerDiv"></div>
6161

6262
<script type="module">
63-
import { Vector3 } from 'three';
6463
import Stats from 'stats-gl';
6564
import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
6665
import { getFormat, getPointCloudClass, getDefaultAttribute, zoomToLayerGlobe } from './jsm/PointCloudHelper.js';
6766

6867
import {
69-
CRS, MAIN_LOOP_EVENTS, PNTS_MODE,
70-
Coordinates,
68+
CRS, MAIN_LOOP_EVENTS,
7169
View,
7270
GlobeView,
7371
Fetcher,
@@ -97,6 +95,7 @@
9795
window.updateUrlParams = updateUrlParams;
9896

9997
let currentView = null;
98+
let gui = null;
10099

101100
window.load = async function load(url, options = {}) {
102101
// Cleanup previous view
@@ -106,6 +105,10 @@
106105
viewerDiv.innerHTML = '';
107106
}
108107

108+
if (gui) {
109+
gui.destroy();
110+
}
111+
109112
const { format = 'auto', crs } = options;
110113
const { Source, Layer } = getPointCloudClass(format);
111114
const attribute = getDefaultAttribute(format);
@@ -162,7 +165,7 @@
162165
view.controls.lookAtCoordinate(options.placement, true);
163166
}
164167

165-
const gui = new GUI();
168+
gui = new GUI();
166169
PointCloudDebug.initTools(view, layer, gui);
167170
}
168171

0 commit comments

Comments
 (0)