fix: remove old model on loading new one

This commit is contained in:
perqin 2021-07-10 16:26:54 +08:00
parent 5649bbf5b6
commit 31ff95cc54

View File

@ -10,6 +10,9 @@ let pixiApp;
*/ */
async function loadlive2dPixi(jsonPath) { async function loadlive2dPixi(jsonPath) {
const model = await PIXI.live2d.Live2DModel.from(jsonPath); const model = await PIXI.live2d.Live2DModel.from(jsonPath);
if (pixiApp.stage.children.length > 0) {
pixiApp.stage.removeChildren(0);
}
pixiApp.stage.addChild(model); pixiApp.stage.addChild(model);
const parentWidth = pixiApp.renderer.width; const parentWidth = pixiApp.renderer.width;
const parentHeight = pixiApp.renderer.height; const parentHeight = pixiApp.renderer.height;