Skip to content

Commit

Permalink
allow to export current selected trait
Browse files Browse the repository at this point in the history
  • Loading branch information
memelotsqui committed Apr 10, 2024
1 parent 38d25f9 commit d70f875
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
17 changes: 13 additions & 4 deletions src/components/ThumbnailCreation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default function ThumbnailCreation({selectedTrait, traitGroupName}){
parentScene.add(sceneElements);
}

const getOptions = () =>{
const getOptions = (exportAll = true) =>{
return {
topFrameOffset:topFrame,
bottomFrameOffset:botFrame,
Expand All @@ -105,18 +105,27 @@ export default function ThumbnailCreation({selectedTrait, traitGroupName}){
cameraPosition:`${xCam-yCam-zCam}`,
topBoneName:topBone,
topBoneMaxVertex:topVertexMax,
// cameraFrame:'cowboyShot',
bottomBoneName:bottomBone,
bottomBoneMaxVertex:bottomVertexMax
bottomBoneMaxVertex:bottomVertexMax,
saveOnlyIDs:exportAll ? null : selectedTrait.id
}
]
}
}

const createCustomThumbnails = async (createAlll = false) => {
const createCustomThumbnails = async (createAll = false) => {
characterManager.storeCurrentAvatar();
//await characterManager.soloTargetGroupTrait(traitGroupName);
const parentScene = sceneElements.parent;
parentScene.remove(sceneElements);
await thumbnailsGenerator.createThumbnailsWithObjectData(getOptions(),createAlll ? 10 : 1,false,false);
if (createAll)
await thumbnailsGenerator.createThumbnailsWithObjectData(getOptions(),10,false);
else
await thumbnailsGenerator.createThumbnailsWithObjectData(getOptions(false),1,false);` `
parentScene.add(sceneElements);

characterManager.loadStoredAvatar();
}


Expand Down
30 changes: 20 additions & 10 deletions src/library/thumbnailsGenerator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as THREE from "three"
import { getVectorCameraPosition } from "./utils";
import { getAsArray, getVectorCameraPosition } from "./utils";
const localVector3 = new THREE.Vector3();

export class ThumbnailGenerator {
Expand Down Expand Up @@ -69,7 +69,8 @@ export class ThumbnailGenerator {
topBoneMaxVertex = true,
groupTopOffset,
groupBotomOffset,
cameraFrame
cameraFrame,
saveOnlyIDs
} = thumbnailInfo;

if (!bottomBoneName || !topBoneName){
Expand All @@ -82,14 +83,27 @@ export class ThumbnailGenerator {
continue;
}

const modelTraits = scope.characterManager.getTraits(traitGroup)

const getSaveOnlyIDs = () => {
const resultArray = [];
const saveOnlyIDArray = getAsArray (saveOnlyIDs);
saveOnlyIDArray.forEach(idValue => {
resultArray.push({id:idValue})
});
return resultArray;
}


const modelTraits = saveOnlyIDs == null ?
scope.characterManager.getTraits(traitGroup):
getSaveOnlyIDs();


if (modelTraits == null){
console.log("SKipping Thumbnail Generation for trait group " + traitGroup + ", its not present in the character manifest.")
continue;
}
console.log("TRAITS", modelTraits);

console.log(modelTraits);
const vectorCameraPosition = getVectorCameraPosition(cameraPosition);
if (cameraFrame){
console.log("frames camera");
Expand All @@ -103,8 +117,7 @@ export class ThumbnailGenerator {
for (let i=0; i < modelTraits.length;i++){
console.log(modelTraits[i].id);
const traitId = modelTraits[i].id;
if (loadTrait)
await scope.characterManager.loadTrait(traitGroup, traitId,true);
await scope.characterManager.loadTrait(traitGroup, traitId,true);
//await scope.animationManager.loadAnimation(animBasePath + poseAnimation, true, finalAnimationTime);
//scope.animationManager.setTime(finalAnimationTime);
await delay(100);
Expand All @@ -114,9 +127,6 @@ export class ThumbnailGenerator {
if (counter >= maxQty){
break;
}
else{
counter++;
}
}
//const saveName = animationName ? animationName : counter.toString().padStart(2, '0');

Expand Down

0 comments on commit d70f875

Please sign in to comment.