-
Notifications
You must be signed in to change notification settings - Fork 0
fix: 애니메이션 GLB 업로드 후 animModelUrl 미갱신 — merge 트리거 누락 #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0d27af6
Merge pull request #187 from Project-Guideon/develop
hwangtae123 3489ae6
Merge pull request #190 from Project-Guideon/develop
yyuneu 3cc57b5
Merge pull request #194 from Project-Guideon/develop
yyuneu 5190d4d
refactor: 마스코트 anim 병합 로직 MascotAnimationMergeService로 추출
yyuneu 3d72362
feat: 애니메이션 GLB 업로드 시점 mesh-processor 자동 병합 트리거
yyuneu 2022d9f
fix: anim 병합 성공여부 반영·중복 clipName·최신 완료 이력 선택 보강
yyuneu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...in/java/com/guideon/guideonbackend/domain/mascot/service/MascotAnimationMergeService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| package com.guideon.guideonbackend.domain.mascot.service; | ||
|
|
||
| import com.guideon.core.domain.mascot.entity.MascotAnimConfig; | ||
| import com.guideon.core.domain.mascot.repository.MascotAnimConfigRepository; | ||
| import com.guideon.guideonbackend.global.storage.FileStorageService; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| /** | ||
| * rig 완료된 마스코트 GLB + 상태별 Mixamo 애니메이션 GLB → 통합 anim GLB 병합. | ||
| * | ||
| * rig 완료 시점(MascotGenerationService)과 | ||
| * 애니메이션 GLB 업로드 시점(MascotAnimConfigService) 양쪽에서 공통으로 호출된다. | ||
| */ | ||
| @Slf4j | ||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class MascotAnimationMergeService { | ||
|
|
||
| private final MascotAnimConfigRepository animConfigRepository; | ||
| private final FileStorageService fileStorageService; | ||
| private final MeshProcessorClient meshProcessorClient; | ||
| private final MascotGenerationPersistService persistService; | ||
|
|
||
| /** | ||
| * anim_config가 설정돼 있고 rig GLB가 존재하면 mesh-processor에 병합을 요청한다. | ||
| * | ||
| * @param siteId 사이트 ID | ||
| * @param generationId MascotGeneration PK (출력 파일명 + DB 업데이트에 사용) | ||
| * @param riggedModelUrl Tripo rig 결과 GLB 서빙 URL | ||
| * @return 병합 성공 시 animModelUrl, anim_config 미설정 또는 병합 실패 시 null | ||
| */ | ||
| public String mergeIfRiggedMascotExists(Long siteId, Long generationId, String riggedModelUrl) { | ||
| List<MascotAnimConfig> animConfigs = animConfigRepository.findBySiteId(siteId); | ||
| if (animConfigs.isEmpty()) { | ||
| log.info("anim_config 미설정 — anim 병합 skip: siteId={}", siteId); | ||
| return null; | ||
| } | ||
|
|
||
| try { | ||
| // clipName이 중복일 때 IllegalStateException 방지 — 첫 번째 값 유지 (a, b) -> a | ||
| Map<String, String> animGlbs = animConfigs.stream().collect(Collectors.toMap( | ||
| MascotAnimConfig::getClipName, | ||
| c -> fileStorageService.toLocalPath(c.getGlbUrl()).toString(), | ||
| (a, b) -> a | ||
| )); | ||
|
|
||
| String riggedLocalPath = fileStorageService.toLocalPath(riggedModelUrl).toString(); | ||
| String animFilename = "anim_" + generationId + ".glb"; | ||
| String animModelUrl = fileStorageService.resolveUrl(siteId, animFilename); | ||
| String animLocalPath = fileStorageService.toLocalPath(animModelUrl).toString(); | ||
|
|
||
| meshProcessorClient.combine(riggedLocalPath, animGlbs, animLocalPath); | ||
|
|
||
| Map<String, String> animClips = animConfigs.stream().collect(Collectors.toMap( | ||
| MascotAnimConfig::getStateKey, | ||
| MascotAnimConfig::getClipName | ||
| )); | ||
| persistService.applyAnimationComplete(siteId, generationId, animModelUrl, animClips); | ||
| log.info("anim GLB 병합 완료: generationId={}, animModelUrl={}", generationId, animModelUrl); | ||
| return animModelUrl; | ||
|
|
||
| } catch (Exception e) { | ||
| log.warn("mesh-processor 실패 — animModelUrl 없이 완료: generationId={}, err={}", | ||
| generationId, e.getMessage()); | ||
| return null; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.