Skip to content

Commit

Permalink
vrm cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
memelotsqui committed Oct 26, 2023
1 parent af540e6 commit 57797b9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/library/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import html2canvas from "html2canvas";
import VRMExporter from "./VRMExporter";
import { CullHiddenFaces } from './cull-mesh.js';
import { combine } from "./merge-geometry";
import { VRMLoaderPlugin } from "@pixiv/three-vrm"
import { VRMLoaderPlugin, VRMUtils } from '@pixiv/three-vrm';
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader"
import { VRMHumanBoneName, VRMHumanBoneParentMap } from "@pixiv/three-vrm";

Expand Down Expand Up @@ -267,7 +267,14 @@ export function disposeVRM(vrm) {
animationControl.dispose();

model.traverse((o) => {

if (o.geometry) {
if (o.userData?.clippedIndexGeometry != null){
o.userData.clippedIndexGeometry = null;
}
if (o.userData?.origIndexBuffer != null){
o.userData.origIndexBuffer = null;
}
o.geometry.dispose();
}

Expand All @@ -282,10 +289,13 @@ export function disposeVRM(vrm) {
}
}
});


if (model.parent) {
model.parent.remove(model);
}

VRMUtils.deepDispose( model );
}
export const createFaceNormals = (geometry) => {
const pos = geometry.attributes.position;
Expand All @@ -311,7 +321,6 @@ export const createBoneDirection = (skinMesh) => {
const geometry = skinMesh.geometry;

const pos = geometry.attributes.position.array;
//console.log(geometry)
const normals = geometry.attributes.normal.array;

// set by jumps of 4
Expand Down

0 comments on commit 57797b9

Please sign in to comment.