From 060e746aac9bafcb3cb3853484ede56182d60fa7 Mon Sep 17 00:00:00 2001 From: Daan Vanden Bosch Date: Wed, 21 Aug 2019 16:55:12 +0200 Subject: [PATCH] Model viewer now pauses and unpauses when switching tools. --- src/new/viewer/stores/ModelStore.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/new/viewer/stores/ModelStore.ts b/src/new/viewer/stores/ModelStore.ts index b77768b5..0b288702 100644 --- a/src/new/viewer/stores/ModelStore.ts +++ b/src/new/viewer/stores/ModelStore.ts @@ -15,6 +15,7 @@ import { property } from "../../core/observable"; import { Property } from "../../core/observable/Property"; import { PSO_FRAME_RATE } from "../../../core/rendering/conversion/ninja_animation"; import { parse_xvm, Xvm } from "../../../core/data_formats/parsing/ninja/texture"; +import { gui_store, GuiTool } from "../../core/stores/GuiStore"; import Logger = require("js-logger"); const logger = Logger.get("viewer/stores/ModelStore"); @@ -78,6 +79,19 @@ export class ModelStore implements Disposable { this.current_model.observe(this.load_model), this.current_animation.observe(this.load_animation), ); + + let prev_animation_playing = this.animation_playing.get(); + + this.disposables.push( + gui_store.tool.observe(tool => { + if (tool === GuiTool.Viewer) { + this.animation_playing.set(prev_animation_playing); + } else { + prev_animation_playing = this.animation_playing.get(); + this.animation_playing.set(false); + } + }), + ); } dispose(): void {