| | |
| | | ease: 'power1.out' |
| | | }) |
| | | } |
| | | |
| | | destroy() { |
| | | this.removeMouseEvent(); |
| | | this.disposeObject(); |
| | | this.removeObject(); |
| | | this.resetObject(); |
| | | } |
| | | |
| | | disposeObject() { |
| | | this.map.traverse((child) => { |
| | | if (child.material) { |
| | | // 可能存在材质为数组的情况 |
| | | if (child.material instanceof Array) { |
| | | child.material.forEach((item) => item.dispose()); |
| | | } else { |
| | | child.material.dispose(); |
| | | if (child.material.map) { |
| | | child.material.map.dispose(); |
| | | } |
| | | } |
| | | } |
| | | if (child.geometry) { |
| | | child.geometry.dispose(); |
| | | child.geometry.attributes = null; // 这些属性包括position, normal, uv等等 |
| | | } |
| | | child = null; |
| | | }); |
| | | this.topFaceMaterial.dispose(); |
| | | this.sideMaterial.dispose(); |
| | | } |
| | | |
| | | removeObject() { |
| | | this.scene.remove(this.map); |
| | | } |
| | | |
| | | resetObject() { |
| | | this.map = null; |
| | | this.provinceMeshList = null; |
| | | this.labelList = null; |
| | | this.textureLoader = null; |
| | | } |
| | | } |