1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| const COLOR_UPDATE_FUNCTION_NAME = ["updatePaletteInfos", "updateQuantization"];
const EYE_UPDATE_FUNCTION_NAME = [ "updateEyeModel", "updateEyeComponentColor", "updateEyeSeperated", ];
const BASE_UPDATE_FUNCTION_NAME = ["updateBaseModel", "updateBaseColor"];
const TRANSFORMCONTROLLER_UPDATE_FUNCTION_NAME = [ "updateModelPosition", "updateModelRotation", "updateModelScale", "resetModel", "resetUndo", "lockedScale", "lockedcaleModel", "updateBaseSeperated", ];
const EMIT_SERIALIZE_FUNCTION_NAME = [ ...EYE_UPDATE_FUNCTION_NAME, ...COLOR_UPDATE_FUNCTION_NAME, ...BASE_UPDATE_FUNCTION_NAME, ];
const handler = { construct(target: any, args: any) { const instance = new target(...args); return new Proxy(instance, { get(target: any, prop: string, receiver: any) { const originalMethod = Reflect.get(target, prop, receiver);
if (EMIT_SERIALIZE_FUNCTION_NAME.includes(prop)) { return (...args: any[]) => { const result = originalMethod.apply(receiver, args);
let targetStep = EditorStep.COLOR; if (EYE_UPDATE_FUNCTION_NAME.includes(prop)) { targetStep = EditorStep.EYES; } if (BASE_UPDATE_FUNCTION_NAME.includes(prop)) { targetStep = EditorStep.BASE; } if (TRANSFORMCONTROLLER_UPDATE_FUNCTION_NAME.includes(prop)) { targetStep = EditorStep.TRANSFORMCONTROLLER; } if (receiver?.store?.step !== targetStep) { receiver?.store?.setStep(targetStep); } return result; }; } return originalMethod; }, }); }, };
|