Skip to content

Commit

Permalink
feat(SVG): dispose of geometries
Browse files Browse the repository at this point in the history
  • Loading branch information
andretchen0 committed Aug 30, 2023
1 parent 95bada9 commit a75d571
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/core/loaders/SVG/component.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { shallowRef, toRefs, watch, watchEffect } from 'vue'
import { shallowRef, toRefs, onUnmounted, watch, watchEffect } from 'vue'
import { TresOptions, useLoader } from '@tresjs/core'
import { SVGLoader, SVGResultPaths } from 'three-stdlib'
import { Vector3, DoubleSide, ShapeGeometry, MeshBasicMaterialParameters, BufferGeometry } from 'three'
Expand Down Expand Up @@ -98,7 +98,14 @@ async function useSVG(src: string) {
return useLoader(SVGLoader, srcStr);
};
onUnmounted(dispose);
function dispose() {
layers.value.forEach(layer => layer.geometry.dispose());
}
function updateLayers() {
dispose();
const _layers = [];
let i = 0;
for (const path of paths.value) {
Expand Down

0 comments on commit a75d571

Please sign in to comment.