@@ -3,7 +3,7 @@ import { v4 as uuid } from 'uuid';
33import { webgalStore } from '@/store/store' ;
44import { setStage , stageActions } from '@/store/stageReducer' ;
55import cloneDeep from 'lodash/cloneDeep' ;
6- import { IEffect , IFigureAssociatedAnimation } from '@/store/stageInterface' ;
6+ import { IEffect , IFigureAssociatedAnimation , IFigureMetadata } from '@/store/stageInterface' ;
77import { logger } from '@/Core/util/logger' ;
88import { isIOS } from '@/Core/initializeScript' ;
99import { WebGALPixiContainer } from '@/Core/controller/stage/pixi/WebGALPixiContainer' ;
@@ -12,7 +12,7 @@ import 'pixi-spine'; // Do this once at the very start of your code. This regist
1212import { Spine } from 'pixi-spine' ;
1313import { SCREEN_CONSTANTS } from '@/Core/util/constants' ;
1414// import { figureCash } from '@/Core/gameScripts/vocal/conentsCash'; // 如果要使用 Live2D,取消这里的注释
15- // import { Live2DModel, SoundManager } from 'pixi-live2d-display'; // 如果要使用 Live2D,取消这里的注释
15+ // import { Live2DModel, SoundManager } from 'pixi-live2d-display-webgal '; // 如果要使用 Live2D,取消这里的注释
1616
1717export interface IAnimationObject {
1818 setStartState : Function ;
@@ -125,6 +125,7 @@ export default class PixiStage {
125125 this . effectsContainer = new PIXI . Container ( ) ;
126126 this . effectsContainer . zIndex = 3 ;
127127 this . figureContainer = new PIXI . Container ( ) ;
128+ this . figureContainer . sortableChildren = true ; // 允许立绘启用 z-index
128129 this . figureContainer . zIndex = 2 ;
129130 this . backgroundContainer = new PIXI . Container ( ) ;
130131 this . backgroundContainer . zIndex = 0 ;
@@ -493,6 +494,12 @@ export default class PixiStage {
493494 this . removeStageObjectByKey ( key ) ;
494495 }
495496
497+ const metadata = this . getFigureMetadataByKey ( key ) ;
498+ if ( metadata ) {
499+ if ( metadata . zIndex ) {
500+ thisFigureContainer . zIndex = metadata . zIndex ;
501+ }
502+ }
496503 // 挂载
497504 this . figureContainer . addChild ( thisFigureContainer ) ;
498505 const figureUuid = uuid ( ) ;
@@ -578,6 +585,12 @@ export default class PixiStage {
578585 this . removeStageObjectByKey ( key ) ;
579586 }
580587
588+ const metadata = this . getFigureMetadataByKey ( key ) ;
589+ if ( metadata ) {
590+ if ( metadata . zIndex ) {
591+ thisFigureContainer . zIndex = metadata . zIndex ;
592+ }
593+ }
581594 // 挂载
582595 this . figureContainer . addChild ( thisFigureContainer ) ;
583596 const figureUuid = uuid ( ) ;
@@ -673,6 +686,12 @@ export default class PixiStage {
673686 // this.removeStageObjectByKey(key);
674687 // }
675688 //
689+ // const metadata = this.getFigureMetadataByKey(key);
690+ // if (metadata) {
691+ // if (metadata.zIndex) {
692+ // thisFigureContainer.zIndex = metadata.zIndex;
693+ // }
694+ // }
676695 // // 挂载
677696 // this.figureContainer.addChild(thisFigureContainer);
678697 // this.figureObjects.push({
@@ -689,7 +708,23 @@ export default class PixiStage {
689708 // const setup = () => {
690709 // if (thisFigureContainer) {
691710 // (async function () {
692- // const models = await Promise.all([Live2DModel.from(jsonPath, { autoInteract: false })]);
711+ // let overrideBounds: [number, number, number, number] = [0, 0, 0, 0];
712+ // const mot = webgalStore.getState().stage.live2dMotion.find((e) => e.target === key);
713+ // if (mot?.overrideBounds) {
714+ // overrideBounds = mot.overrideBounds;
715+ // }
716+ // console.log(overrideBounds);
717+ // const models = await Promise.all([
718+ // Live2DModel.from(jsonPath, {
719+ // autoInteract: false,
720+ // overWriteBounds: {
721+ // x0: overrideBounds[0],
722+ // y0: overrideBounds[1],
723+ // x1: overrideBounds[2],
724+ // y1: overrideBounds[3],
725+ // },
726+ // }),
727+ // ]);
693728 //
694729 // models.forEach((model) => {
695730 // const scaleX = stageWidth / model.width;
@@ -962,6 +997,11 @@ export default class PixiStage {
962997 private getExtName ( url : string ) {
963998 return url . split ( '.' ) . pop ( ) ?? 'png' ;
964999 }
1000+
1001+ private getFigureMetadataByKey ( key : string ) : IFigureMetadata | undefined {
1002+ console . log ( key , webgalStore . getState ( ) . stage . figureMetaData ) ;
1003+ return webgalStore . getState ( ) . stage . figureMetaData [ key ] ;
1004+ }
9651005}
9661006
9671007function updateCurrentBacklogEffects ( newEffects : IEffect [ ] ) {
0 commit comments