diff --git a/web/js/threeVisualizer.js b/web/js/threeVisualizer.js index 771be20..be2f9af 100644 --- a/web/js/threeVisualizer.js +++ b/web/js/threeVisualizer.js @@ -51,9 +51,11 @@ window.onresize = function () { }; +const clock = new THREE.Clock(); var lastTimestamp = ""; var needUpdate = false; +let mixer; function frameUpdate() { @@ -62,6 +64,10 @@ function frameUpdate() { if (timestamp == lastTimestamp){ if (needUpdate){ controls.update(); + if (mixer !== undefined) { + const delta = clock.getDelta(); + mixer.update(delta); + } renderer.render( scene, camera ); } requestAnimationFrame( frameUpdate ); @@ -138,6 +144,10 @@ async function main(filepath="") { model.scale.set( 5, 5, 5 ); scene.add( model ); + mixer = new THREE.AnimationMixer(model); + gltf.animations.forEach((clip) => { + mixer.clipAction(clip).play(); + }); }, onProgress, onError ); @@ -159,4 +169,4 @@ async function main(filepath="") { } //main("C:/Users/reall/Softwares/ComfyUI_windows_portable/ComfyUI/output/MeshTest/Mesh_01.obj"); -main(); \ No newline at end of file +main();