Merge pull request #188 from yashschandra/main

add animation mixer for glb files
This commit is contained in:
Mr. For Example
2024-07-03 16:12:25 -06:00
committed by GitHub
+11 -1
View File
@@ -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 );
@@ -136,6 +142,10 @@ async function main(filepath="") {
model.scale.set( 3, 3, 3 );
scene.add( model );
mixer = new THREE.AnimationMixer(model);
gltf.animations.forEach((clip) => {
mixer.clipAction(clip).play();
});
}, onProgress, onError );
@@ -157,4 +167,4 @@ async function main(filepath="") {
}
//main("C:/Users/reall/Softwares/ComfyUI_windows_portable/ComfyUI/output/MeshTest/Mesh_01.obj");
main();
main();