Skip to content
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

[wip] Wallet Integration #152

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 37 additions & 17 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,47 @@
"characters":[
{
"name": "Anata",
"description": "Anata",
"description": "Owned Customizer",
"portrait": "./assets/portraitImages/anata.png",
"manifest":"./character-assets/anata/manifest.json",
"icon": "./assets/icons/class-neural-hacker.svg",
"format": "vrm"
"format": "vrm",
"collectionLock":"the-anata-nft",
"manifestAppend":[
{
"name": "Loot",
"description": "Adventurere's loot",
"manifest":"./loot-assets/anata/female/manifest.json",
"collectionLock":"lootproject"
}
]
},
{
"name": "Anata Male",
"description": "Anata Male",
"name": "Anata",
"description": "Full Customizer",
"portrait": "./assets/portraitImages/anata_male.png",
"manifest":"./character-assets/anata_male/manifest.json",
"icon": "|",
"format": "vrm"
"icon": "./assets/icons/class-neural-hacker.svg",
"format": "vrm",
"collectionLock":"the-anata-nft",
"fullTraits":true
},
{
"name": "Anata Male",
"description": "Anata Male",
"portrait": "./assets/portraitImages/anata_male.png",
"manifest":"./character-assets/test.json",
"icon": "|",
"format": "vrm"
"name": "Tubbies",
"description": "Tubbies",
"portrait": "./assets/portraitImages/anata.png",
"manifest":"./tubby/manifest.json",
"icon": "./assets/icons/class-neural-hacker.svg",
"format": "vrm",
"manifestAppend":[
{
"name": "Loot",
"description": "Adventurere's loot",
"manifest":"./loot-assets/tubbycats/manifest.json",
"collectionLock":"lootproject",
"fullTraits":true
}
]
}
],
"loras":[
Expand Down Expand Up @@ -59,26 +79,26 @@
"defaultAnimations":[
{
"name": "T-Pose",
"description": "T-Pose",
"description": "1_T-Pose",
"location":"./animations/T-Pose.fbx",
"icon": "|"
},
{
"name": "Dancing",
"name": "Idle",
"description": "Basic Dance Animation",
"location":"./animations/Dancing.fbx",
"location":"./animations/2_Idle.fbx",
"icon": "|"
},
{
"name": "Walking",
"description": "Basic Walk Animation",
"location":"./animations/Walking.fbx",
"location":"./animations/3_Walking.fbx",
"icon": "|"
},
{
"name": "Waving",
"description": "Basic Waving Animation",
"location":"./animations/Waving.fbx",
"location":"./animations/4_Waving.fbx",
"icon": "|"
}
]
Expand Down
108 changes: 77 additions & 31 deletions src/library/CharacterManifestData.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getAsArray } from "./utils";

export class CharacterManifestData{
constructor(manifest){
constructor(manifest, unlockedTraits = null){
const {
assetsLocation,
traitsDirectory,
Expand Down Expand Up @@ -99,19 +99,19 @@ export class CharacterManifestData{
}
defaultOptions();


// create texture and color traits first
this.textureTraits = [];
this.textureTraitsMap = null;
this.createTextureTraits(textureCollections);
this.createTextureTraits(textureCollections, false, unlockedTraits);

this.colorTraits = [];
this.colorTraitsMap = null;
this.createColorTraits(colorCollections);
this.createColorTraits(colorCollections, false, unlockedTraits);

this.modelTraits = [];
this.modelTraitsMap = null;
this.createModelTraits(traits);
this.createModelTraits(traits, false, unlockedTraits);
}
appendManifestData(manifestData, replaceExisting){
manifestData.textureTraits.forEach(newTextureTraitGroup => {
Expand Down Expand Up @@ -361,11 +361,10 @@ export class CharacterManifestData{


// Given an array of traits, saves an array of TraitModels
createModelTraits(modelTraits, replaceExisting = false){
createModelTraits(modelTraits, replaceExisting = false, unlockedTraits = null){
if (replaceExisting) this.modelTraits = [];

getAsArray(modelTraits).forEach(traitObject => {
this.modelTraits.push(new TraitModelsGroup(this, traitObject))
this.modelTraits.push(new TraitModelsGroup(this, traitObject, unlockedTraits))
});

this.modelTraitsMap = new Map(this.modelTraits.map(item => [item.trait, item]));
Expand All @@ -382,21 +381,21 @@ export class CharacterManifestData{
});
}

createTextureTraits(textureTraits, replaceExisting = false){
createTextureTraits(textureTraits, replaceExisting = false, unlockedTraits = null){
if (replaceExisting) this.textureTraits = [];

getAsArray(textureTraits).forEach(traitObject => {
this.textureTraits.push(new TraitTexturesGroup(this, traitObject))
this.textureTraits.push(new TraitTexturesGroup(this, traitObject, unlockedTraits))
});

this.textureTraitsMap = new Map(this.textureTraits.map(item => [item.trait, item]));
}

createColorTraits(colorTraits, replaceExisting = false){
createColorTraits(colorTraits, replaceExisting = false, unlockedTraits = null){
if (replaceExisting) this.colorTraits = [];

getAsArray(colorTraits).forEach(traitObject => {
this.colorTraits.push(new TraitColorsGroup(this, traitObject))
this.colorTraits.push(new TraitColorsGroup(this, traitObject, unlockedTraits))
});

this.colorTraitsMap = new Map(this.colorTraits.map(item => [item.trait, item]));
Expand All @@ -407,7 +406,7 @@ export class CharacterManifestData{

// Must be created AFTER color collections and texture collections have been created
class TraitModelsGroup{
constructor(manifestData, options){
constructor(manifestData, options, unlockedTraits = null){
const {
trait,
name,
Expand All @@ -420,7 +419,7 @@ class TraitModelsGroup{
restrictedTypes = []
} = options;
this.manifestData = manifestData;

this.isRequired = manifestData.requiredTraits.indexOf(trait) !== -1;
this.trait = trait;
this.name = name;
Expand All @@ -436,7 +435,15 @@ class TraitModelsGroup{

this.collection = [];
this.collectionMap = null;
this.createCollection(collection);
if (unlockedTraits == null){
this.createCollection(collection);
}
else{
const finalUnlockedTraits = Array.isArray(unlockedTraits) ? unlockedTraits : unlockedTraits[trait]
console.log("UNLOCKED", finalUnlockedTraits,);
this.createCollection(collection, false, finalUnlockedTraits || []);
}

}

appendCollection(modelTraitGroup, replaceExisting){
Expand Down Expand Up @@ -467,12 +474,21 @@ class TraitModelsGroup{
}
}

createCollection(itemCollection, replaceExisting = false){
createCollection(itemCollection, replaceExisting = false, unlockedTraits = null){
if (replaceExisting) this.collection = [];

getAsArray(itemCollection).forEach(item => {
this.collection.push(new ModelTrait(this, item))
});
if (unlockedTraits == null){
getAsArray(itemCollection).forEach(item => {
this.collection.push(new ModelTrait(this, item))
});
}
else{
getAsArray(itemCollection).forEach(item => {
if (unlockedTraits.includes(item.id)){
this.collection.push(new ModelTrait(this, item))
}
});
}
this.collectionMap = new Map(this.collection.map(item => [item.id, item]));
}

Expand Down Expand Up @@ -506,7 +522,7 @@ class TraitModelsGroup{

}
class TraitTexturesGroup{
constructor(manifestData, options){
constructor(manifestData, options, unlockedTraits = null){
const {
trait,
collection
Expand All @@ -516,7 +532,13 @@ class TraitTexturesGroup{

this.collection = [];
this.collectionMap = null;
this.createCollection(collection);

if (unlockedTraits == null){
this.createCollection(collection);
}
else{
this.createCollection(collection, false, unlockedTraits[trait] || []);
}


}
Expand All @@ -543,12 +565,21 @@ class TraitTexturesGroup{
}
});
}
createCollection(itemCollection, replaceExisting = false){
createCollection(itemCollection, replaceExisting = false, unlockedTraits = null){
if (replaceExisting) this.collection = [];

getAsArray(itemCollection).forEach(item => {
this.collection.push(new TextureTrait(this, item))
});
if (unlockedTraits == null){
getAsArray(itemCollection).forEach(item => {
this.collection.push(new TextureTrait(this, item))
});
}
else{
getAsArray(itemCollection).forEach(item => {
if (unlockedTraits.includes(item.id)){
this.collection.push(new TextureTrait(this, item))
}
});
}
this.collectionMap = new Map(this.collection.map(item => [item.id, item]));
}

Expand All @@ -567,7 +598,7 @@ class TraitTexturesGroup{
}
}
class TraitColorsGroup{
constructor(manifestData, options){
constructor(manifestData, options, unlockedTraits = null){
const {
trait,
collection
Expand All @@ -577,7 +608,13 @@ class TraitColorsGroup{

this.collection = [];
this.collectionMap = null;
this.createCollection(collection);

if (unlockedTraits == null){
this.createCollection(collection);
}
else{
this.createCollection(collection, false, unlockedTraits[trait] || []);
}
}

appendCollection(colorTraitGroup, replaceExisting){
Expand All @@ -602,12 +639,21 @@ class TraitColorsGroup{
}
});
}
createCollection(itemCollection, replaceExisting = false){
createCollection(itemCollection, replaceExisting = false, unlockedTraits = null){
if (replaceExisting) this.collection = [];

getAsArray(itemCollection).forEach(item => {
this.collection.push(new ColorTrait(this, item))
});
if (unlockedTraits == null){
getAsArray(itemCollection).forEach(item => {
this.collection.push(new ColorTrait(this, item))
});
}
else{
getAsArray(itemCollection).forEach(item => {
if (unlockedTraits.includes(item.id)){
this.collection.push(new ColorTrait(this, item))
}
});
}
this.collectionMap = new Map(this.collection.map(item => [item.id, item]));
}

Expand Down
Loading