Import a 3D Model and automatically assign and export animations
TypeScript
Attempt to dispose three.js objects when regenerating weight painting
Scott Petroviced5b2e7a7cdb
diff --git a/src/lib/processes/weight-skin/StepWeightSkin.ts b/src/lib/processes/weight-skin/StepWeightSkin.tsindex f367001..30ae49a 100644--- a/src/lib/processes/weight-skin/StepWeightSkin.ts+++ b/src/lib/processes/weight-skin/StepWeightSkin.ts@@ -99,6 +99,26 @@ export class StepWeightSkin extends EventTarget {this.skinned_meshes = []this.all_mesh_materials = []this.all_mesh_geometry = []++ // https://github.com/Mesh2Motion/mesh2motion-app/issues/82+ // Properly dispose of all children in the weight painted mesh preview to prevent memory leaks+ // It didn't seem to make much of a difference for Scott, but maybe it helps others+ this.weight_painted_mesh_preview.children.forEach((child) => {+ if (child instanceof SkinnedMesh || 'geometry' in child) {+ const mesh = child as any+ if (mesh.geometry) {+ mesh.geometry.dispose()+ }+ if (mesh.material) {+ if (Array.isArray(mesh.material)) {+ mesh.material.forEach((mat: Material) => mat.dispose())+ } else {+ mesh.material.dispose()+ }+ }+ }+ })+this.weight_painted_mesh_preview.clear()}