{
  "name": "play-animations",
  "description": "play scene animations and get animations mixers",
  "dependencies": [
    "three"
  ],
  "devDependencies": [
    "@types/three"
  ],
  "registryDependencies": [
    "create-viewer"
  ],
  "files": [
    {
      "path": "get-animation-mixers.ts",
      "content": "import { AnimationMixer, Object3D, Scene } from \"three\";\n\nexport const getAnimationMixers = (scene: Scene) => {\n  const animationMixers: AnimationMixer[] = [];\n  scene.traverse((object: Object3D) => {\n    if (object.animations.length != 0) {\n      let mixer = object.userData[\"animationMixer\"];\n      if (!mixer) {\n        mixer = new AnimationMixer(object);\n        object.userData[\"animationMixer\"] = mixer;\n      }\n      object.animations.forEach((clip) => {\n        const action = mixer.clipAction(clip);\n        action.play();\n      });\n      animationMixers.push(mixer);\n    }\n  });\n  return animationMixers;\n\n}\n"
    },
    {
      "path": "play-animations.ts",
      "content": "import { ViewerEvent } from \"@3dvf/create-viewer/create-viewer\";\nimport { EventDispatcher, Scene } from \"three\";\nimport { getAnimationMixers } from \"./get-animation-mixers\";\n\nexport const playAnimations = (scene: Scene, eventDispatcher: EventDispatcher<ViewerEvent>) => {\n  const animationMixers = getAnimationMixers(scene);\n  animationMixers.forEach(animationMixer => {\n    eventDispatcher.addEventListener(\"animate\", ({ delta }) => {\n      animationMixer.update(delta);\n    });\n  });\n}\n"
    }
  ]
}