diff --git a/app/components/Form.tsx b/app/components/Form.tsx index ab47784..10d871a 100644 --- a/app/components/Form.tsx +++ b/app/components/Form.tsx @@ -166,13 +166,12 @@ export function Form() { if (!sceneView) return; sceneView.toggleLayerVisibility(name); - sceneView.dispatchChangeEvent(); } function handleChangeTopography() { if (!sceneView) return; - sceneView.toggleTopography(); + sceneView.toggleLayerVisibility("Topography"); } function handleDrilling(e: ChangeEvent) { diff --git a/app/three/SceneView.ts b/app/three/SceneView.ts index 02de088..67457b1 100644 --- a/app/three/SceneView.ts +++ b/app/three/SceneView.ts @@ -129,7 +129,7 @@ export class SceneView extends EventTarget { if (capMeshGroup) { for (const m of capMeshGroup.children) { - if (m.name === layerName && m) { + if (m && m.name === layerName) { m.visible = !m.visible; } } @@ -171,13 +171,6 @@ export class SceneView extends EventTarget { } } - toggleTopography() { - const topo = this._scene.getObjectByName("Topography"); - if (topo) { - topo.visible = !topo.visible; - } - } - private _onPointerClick(event: MouseEvent) { // Convert screen position to NDC (-1 to +1 range) const pointer = new Vector2(); @@ -434,10 +427,6 @@ export class SceneView extends EventTarget { this._resetClippingBox(); } } - - dispatchChangeEvent() { - this._orbitControls.dispatchEvent({ type: "change" }); - } } async function init(container: HTMLElement, modelId = MODEL_ID) {