Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat: character-studio library updates
nirholasc990e6da14ed
diff --git a/character-studio/src/library/VRMExporterv0.js b/character-studio/src/library/VRMExporterv0.jsindex aad25ebd0..dbead6a34 100644--- a/character-studio/src/library/VRMExporterv0.js+++ b/character-studio/src/library/VRMExporterv0.js@@ -1,34 +1,10 @@-import { BufferAttribute, Euler, Vector3 } from "three";+import { BufferAttribute, Vector3 } from "three";import { VRMExpressionPresetName } from "@pixiv/three-vrm";-import { encodeToKTX2 } from 'ktx2-encoder';-import { KtxDecoder } from "./ktx";import { KTXTools } from "./ktxtools";-function ToOutputVRMMeta(vrmMeta, icon, outputImage) {- return {- allowedUserName: vrmMeta.allowedUserName,- author: vrmMeta.author,- commercialUssageName: vrmMeta.commercialUssageName,- contactInformation: vrmMeta.contactInformation,- licenseName: vrmMeta.licenseName,- otherLicenseUrl: vrmMeta.otherLicenseUrl,- otherPermissionUrl: vrmMeta.otherPermissionUrl,- reference: vrmMeta.reference,- sexualUssageName: vrmMeta.sexualUssageName,- texture: icon ? outputImage.length - 1 : undefined,- title: vrmMeta.title,- version: vrmMeta.version,- violentUssageName: vrmMeta.violentUssageName,- };-}---const debug = false;--// WebGL(OpenGL)マクロ定数var WEBGL_CONST;(function (WEBGL_CONST) {@@ -44,13 +20,7 @@ var WEBGL_CONST;WEBGL_CONST[WEBGL_CONST["REPEAT"] = 10497] = "REPEAT";})(WEBGL_CONST || (WEBGL_CONST = {}));const BLENDSHAPE_PREFIX = "blend_";-const MORPH_CONTROLLER_PREFIX = "BlendShapeController_";const SPRINGBONE_COLLIDER_NAME = "vrmColliderSphere";-const EXPORTER_VERSION = "alpha-v1.0";-const CHUNK_TYPE_JSON = "JSON";-const CHUNK_TYPE_BIN = "BIN\x00";-const GLTF_VERSION = 2;-const HEADER_SIZE = 12;function convertMetaToVRM0(meta) {return {title: meta.name,@@ -239,7 +209,7 @@ export default class VRMExporterv0 {child.type === VRMObjectType.SkinnedMesh);const meshDatas = [];- meshes.forEach((object, meshindex) => {+ meshes.forEach((object) => {const mesh = (object.type === VRMObjectType.Group? object.children[0]: object);@@ -874,9 +844,6 @@ function fillVRMMissingMetaData(vrmMeta) {vrmMeta.otherLicenseUrl = vrmMeta.otherLicenseUrl || "";}-function radian2Degree(radian) {- return radian * (180 / Math.PI);-}function getNodes(parentNode) {if (parentNode.children.length <= 0)return [parentNode];@@ -1340,7 +1307,7 @@ const toOutputSkins = (meshes, meshDatas, nodeNames) => {const toOutputMaterials = (uniqueMaterials, images) => {return uniqueMaterials.map((material) => {let baseColor;- let VRMC_materials_mtoon = null;+ let VRMC_materials_mtoon;material = material.userData.vrmMaterial ? material.userData.vrmMaterial : material;if (material.type === "ShaderMaterial") {@@ -1506,56 +1473,3 @@ const toOutputScenes = (avatar, outputNodes) => {},];};-const toOutputSecondaryAnimation = (springBone, nodeNames) => {- return {- boneGroups: springBone.springBoneGroupList[0] &&- springBone.springBoneGroupList[0].length > 0- ? springBone.springBoneGroupList.map((group) => ({- bones: group.map((e) => nodeNames.indexOf(e.bone.name)),- center: group[0].center- ? nodeNames.indexOf(group[0].center.name) // TODO: nullになっていて実際のデータはわからん- : -1,- colliderGroups: springBone.colliderGroups.map((_, index) => index),- dragForce: group[0].dragForce,- gravityDir: {- x: group[0].gravityDir.x,- y: group[0].gravityDir.y,- z: group[0].gravityDir.z, // TODO: それっぽいやつをいれた- },- gravityPower: group[0].gravityPower,- hitRadius: group[0].radius,- stiffiness: group[0].stiffnessForce, // TODO: それっぽいやつをいれた- }))- : [- {- bones: [],- center: -1,- colliderGroups: [],- dragForce: 0.4,- gravityDir: {- x: 0,- y: -1,- z: 0,- },- gravityPower: 0,- hitRadius: 0.02,- stiffiness: 1,- },- ],- colliderGroups: springBone.colliderGroups.map((group) => ({- colliders: [- {- offset: {- x: group.colliders[0].position.x,- y: group.colliders[0].position.y,- z: group.colliders[0].position.z,- },- radius: group.colliders[0].geometry.boundingSphere- ? group.colliders[0].geometry.boundingSphere.radius- : undefined,- },- ],- node: group.node,- })),- };-};\ No newline at end of filediff --git a/character-studio/src/library/characterManager.js b/character-studio/src/library/characterManager.jsindex fce7d0c9c..3841ae591 100644--- a/character-studio/src/library/characterManager.js+++ b/character-studio/src/library/characterManager.js@@ -118,7 +118,7 @@ export class CharacterManager {* @param {boolean} x - true to pause, false to unpause*/togglePauseSpringBoneAnimation(x){- for(const [_,trait] of Object.entries(this.avatar)){+ for(const [,trait] of Object.entries(this.avatar)){if(trait.vrm.springBoneManager){trait.vrm.springBoneManager.paused =x}@@ -144,10 +144,6 @@ export class CharacterManager {}}}- unlockManifestByIndex(index, testWallet = null){- console.log(index);- return this.manifestDataManager.unlockManifestByIndex(index, testWallet);- }unlockManifestByIdentifier(identifier, testWallet = null){return this.manifestDataManager.unlockManifestByIdentifier(identifier, testWallet);}@@ -174,7 +170,7 @@ export class CharacterManager {* @param {THREE.Camera} camera - Camera used for look-at calculations* @param {boolean} [enable=true] - Whether to enable the behavior immediately*/- addLookAtMouse(screenPrecentage, canvasID, camera, enable = true){+ addLookAtMouse(screenPrecentage, canvasID, camera){this.lookAtManager = new LookAtManager(screenPrecentage, canvasID, camera);this.lookAtManager.enabled = true;for (const prop in this.avatar){@@ -333,7 +329,8 @@ export class CharacterManager {* @returns {Promise<void>} Promise that resolves when download is complete*/downloadVRM(name, exportOptions = null) {- return new Promise(async (resolve, reject) => {+ return new Promise((resolve, reject) => {+ (async () => {if (this.canDownload()) {try {// Set default export options if not provided@@ -361,6 +358,7 @@ export class CharacterManager {console.error(errorMessage);reject(new Error(errorMessage));}+ })().catch(reject);});}downloadGLB(name, exportOptions = null){@@ -519,7 +517,8 @@ export class CharacterManager {* @returns {Promise<void>} Promise that resolves when traits are loaded*/loadRandomTraits() {- return new Promise(async (resolve, reject) => {+ return new Promise((resolve, reject) => {+ (async () => {if (this.manifestDataManager.hasExistingManifest()) {const randomTraits = this.manifestDataManager.getRandomTraits();await this._loadTraits(randomTraits);@@ -529,6 +528,7 @@ export class CharacterManager {console.error(errorMessage);reject(new Error(errorMessage)); // Reject the promise with an error}+ })().catch(reject);});}/**@@ -537,7 +537,8 @@ export class CharacterManager {* @returns {Promise<void>} Promise that resolves when trait is loaded*/loadRandomTrait(groupTraitID) {- return new Promise(async (resolve, reject) => {+ return new Promise((resolve, reject) => {+ (async () => {if (this.manifestDataManager.hasExistingManifest()) {const randomTrait = this.manifestDataManager.getRandomTrait(groupTraitID);await this._loadTraits(getAsArray(randomTrait));@@ -547,6 +548,7 @@ export class CharacterManager {console.error(errorMessage);reject(new Error(errorMessage)); // Reject the promise with an error}+ })().catch(reject);});}@@ -560,7 +562,8 @@ export class CharacterManager {*/loadTraitsFromNFT(url, identifier = null, fullAvatarReplace = true, ignoreGroupTraits = null) {// XXX should identifier be taken from nft group or passed by user?- return new Promise(async (resolve, reject) => {+ return new Promise((resolve, reject) => {+ (async () => {try {// Check if manifest data is availableif (this.manifestDataManager.hasExistingManifest()) {@@ -582,6 +585,7 @@ export class CharacterManager {// Handle any asynchronous errors during trait retrieval or loadingreject(error);}+ })().catch(reject);});}@@ -911,7 +915,7 @@ export class CharacterManager {});} catch (error) {console.error("Error setting trait color:", error.message);- throw new Error("Failed to set trait color.");+ throw new Error("Failed to set trait color.", { cause: error });}} else {// Group trait not found, log a warning and throw an error@@ -1414,7 +1418,7 @@ export class CharacterManager {const getColliders = ()=>{const colliderGroups = []- Object.entries(this.avatar).map(([_, entry]) => {+ Object.entries(this.avatar).map(([, entry]) => {// get nodes with collidersconst nodes = getNodesWithColliders(entry.vrm)if (nodes.length === 0) returndiff --git a/character-studio/src/library/create-texture-atlas.js b/character-studio/src/library/create-texture-atlas.jsindex d2cfd5466..321d0ab30 100644--- a/character-studio/src/library/create-texture-atlas.js+++ b/character-studio/src/library/create-texture-atlas.js@@ -43,7 +43,7 @@ export const createTextureAtlas = async ({ transparentColor, meshes, includeNonT}};-export const createTextureAtlasNode = async ({ meshes, atlasSize, mtoon, transparentMaterial, transparentTexture }) => {+export const createTextureAtlasNode = async ({ meshes, atlasSize, transparentTexture }) => {const ATLAS_SIZE_PX = atlasSize;const IMAGE_NAMES = ["diffuse"];const bakeObjects = [];@@ -168,7 +168,7 @@ export const createTextureAtlasNode = async ({ meshes, atlasSize, mtoon, transpa* @param {boolean} params.twoSidedMaterial - Whether the material is two-sided.* @param {number} params.scale - The scale factor for the meshes.*/-export const createTextureAtlasBrowser = async ({ backColor, includeNonTexturedMeshesInAtlas=false,meshes, atlasSize, mtoon, transparentMaterial, transparentTexture, twoSidedMaterial, scale=1}) => {+export const createTextureAtlasBrowser = async ({ backColor, includeNonTexturedMeshesInAtlas=false,meshes, atlasSize, mtoon, transparentMaterial, transparentTexture, twoSidedMaterial}) => {const ATLAS_SIZE_PX = atlasSize;const IMAGE_NAMES = mtoon ? ["diffuse"] : ["diffuse", "orm", "normal"];// not using normal texture for nowconst bakeObjects = [];diff --git a/character-studio/src/library/download-utils.js b/character-studio/src/library/download-utils.jsindex bb6ec4361..83740350d 100644--- a/character-studio/src/library/download-utils.js+++ b/character-studio/src/library/download-utils.js@@ -1,11 +1,10 @@-import { Group, MeshStandardMaterial, Color } from "three"+import { Group, MeshStandardMaterial } from "three"import { GLTFExporter } from "three/examples/jsm/exporters/GLTFExporter"import { cloneSkeleton, combine, combineNoAtlas } from "./merge-geometry"import VRMExporter from "./VRMExporter"import VRMExporterv0 from "./VRMExporterv0"import { findChildrenByType } from "./utils"-import { VRMHumanBoneName, VRMExpression, VRMExpressionPresetName, VRMExpressionManager, VRMExpressionMorphTargetBind} from "@pixiv/three-vrm";-import { doesMeshHaveMorphTargetBoundToManager } from './utils';+import { VRMHumanBoneName, VRMExpression, VRMExpressionPresetName, VRMExpressionManager} from "@pixiv/three-vrm";import { GetMetadataFromAvatar } from "./vrmMetaUtils"@@ -81,19 +80,6 @@ export async function getVRMBlobData(model, avatar, options){return new Blob([vrm], { type: 'model/gltf-binary' });}-// returns a promise with the parsed data-async function getGLBData(model, options){- const {optimized = true} = options;- if (optimized){- const finalModel = await getOptimizedGLB(model, options)- return parseGLB(finalModel);- }- else{- const finalModel = getUnopotimizedGLB(model)- return parseGLB(finalModel);- }-}-/*** Downloads a VRM model with specified options.*@@ -123,7 +109,7 @@ export async function downloadVRM(model,vrmData,fileName, options){}export function downloadVRMWithAvatar(model, avatar, fileName, options){- return new Promise(async (resolve, reject) => {+ return new Promise((resolve) => {const downloadFileName = `${fileName && fileName !== "" ? fileName : "AvatarCreatorModel"}`@@ -193,7 +179,7 @@ function parseGLB (glbModel){truncateDrawRange: true,binary: true,forcePowerOfTwoTextures: false,- maxTextureSize: 1024 || Infinity,+ maxTextureSize: 1024,},)})@@ -361,8 +347,7 @@ function getVRMMeta( vrmMeta){function parseVRM (glbModel, avatar, options){const {- screenshot = null,- isVrm0 = false,+ screenshot = null,vrmMeta = null,scale = 1,vrmName = "CharacterCreator"@@ -372,7 +357,7 @@ function parseVRM (glbModel, avatar, options){- return new Promise(async (resolve) => {+ return new Promise((resolve) => {/*** Because vrm1 Exporter is broken, always default to vrm0 exporter;*/@@ -459,7 +444,6 @@ function getVRMBaseData(avatar) {* @param {THREE.Object3D} avatarModel - The avatar model.*/function getRebindedVRMExpressionManager(avatarModel){- const expressionManager = new VRMExpressionManager();// Get old expression manager or a new default one if it doesnt exist/*** @type {THREE.VRMExpressionManager|undefined}@@ -474,176 +458,5 @@ function getRebindedVRMExpressionManager(avatarModel){}return oldExpressionManager;- // Copy the old expression manager- expressionManager.copy(oldExpressionManager);- // Remove reference to the old expression manager- avatarModel.userData.expressionManagerToClone = null-- for(const child of avatarModel.children){- if(!child.isMesh && !child.isSkinnedMesh) continue;-- if(!child.morphTargetDictionary) continue-- /**- * @type {{- * new:{[key:string]:{- * index:number,- * primitives:number[]- *}},- * old:{[key:string]:{- * index:number,- * primitives:number[]- *}}- *}}- */- const changedDictionaries = child.userData.bindMorphs-- // If the child has no changed dictionaries, skip- if(!changedDictionaries) continue-- // If the child has no blendshape that is in the expression manager, skip- const hasBlendshape = doesMeshHaveMorphTargetBoundToManager(child, changedDictionaries.old)- if(!hasBlendshape) continue-- /**- * Get Weight from previous bind- * @param {Object[]} binds- * @param {number} indexToLookFor- */- const getPrevBoundWeight = (binds,indexToLookFor) => {- return binds.find((bind) => bind.index == indexToLookFor)?.weight||0- }-- const VRMExpressionNames = Object.entries(VRMExpressionPresetName).flat()- // List of expressions keys that can be removed- const expressionsToUnBind = Object.keys(changedDictionaries.old).filter((key) => VRMExpressionNames.includes(key));-- // Iterate through all old expressions- for(const item of Object.keys(oldExpressionManager.expressionMap)){- const expression = oldExpressionManager.expressionMap[item];- if(!expression) continue- const prevBounds = expression._binds- if(!prevBounds || prevBounds.length==0) {- // No binds, remove the expression- expressionManager.unregisterExpression(expression)- continue- }-- // Go through all blendshapes bound to old expressions- for(const morph of expressionsToUnBind){- const blendShapeKeyEntry = changedDictionaries.new[morph] || changedDictionaries.new[morph.toLowerCase()]- const blendShapeKeyEntryOld = changedDictionaries.old[morph] || changedDictionaries.old[morph.toLowerCase()]- if(blendShapeKeyEntry){- // Get all meshes that are bound to the expression- const meshes = []- avatarModel.traverse((o)=>{- if(!o.isMesh && !o.isSkinnedMesh) return- if(blendShapeKeyEntry.primitives.includes(o.id)){- meshes.push(o)- }- })- // Unregister the old expression- expressionManager.unregisterExpression(expression)- // remove all binds from the old expression- // commented out, subsequent downloads were having issues: binds were removed- // expression._binds = []- // get weight from previous bind- const weight = getPrevBoundWeight(prevBounds,blendShapeKeyEntryOld.index);- // Create a new expression with the same name- const newExpression = new VRMExpression(expression.expressionName)- // Copy the old expression (no binds)- newExpression.copy(expression)- // Add the new bind- console.log('adding bind',expression.expressionName)- newExpression.addBind(new VRMExpressionMorphTargetBind({- index:blendShapeKeyEntry.index,- weight:weight,- primitives:meshes- }))-- // Register the new expression- expressionManager.registerExpression(newExpression)- }else{- expressionManager.unregisterExpression(expression)- }- }-- }-- /**- * Rebind the new blendshape to the expression manager- */- for(const expression of expressionManager.expressions){- const blendshapeNames = getBlendshapeNameByBindsForVRMExpression(expression)- const defaultBlendshape = blendshapeNames[0][0];-- const oldBounds = (expression)._binds-- if(!changedDictionaries.new[defaultBlendshape]) continue;- const newBindIndex = changedDictionaries.new[defaultBlendshape].index- /**- * {- index:number,- weight:number,- primitives:THREE.SkinnedMesh[]- }[]- */- const jsonBinds = []- oldBounds.map((bind)=>{- let alreadyBound = jsonBinds.find((b)=>b.index == newBindIndex)- if(alreadyBound?.primitives.map((p)=>p.id).includes(child.id)){- // already bound, skip- return- }else if (alreadyBound){- alreadyBound.primitives.push(child)- }else{- jsonBinds.push({- index:newBindIndex,- weight:bind.weight,- primitives:[child]- })- }-- })-- const vrmBinds = jsonBinds.map((bind)=>{- return new VRMExpressionMorphTargetBind(bind)- })-- if(expression.userData.processed){- //@ts-ignore- expression._binds.push(...vrmBinds)- }else{- expression.userData.processed = true;- //@ts-ignore- expression._binds = vrmBinds- }- }-- }-- return expressionManager}-/**- * Get list of blendshape Names for each mesh in each bind of the expression- */-function getBlendshapeNameByBindsForVRMExpression(expression){-- const binds = expression._binds- if(!binds) return []-- const blendshapes = binds.map((bind) => {- let blendshapeNames = []- bind.primitives.forEach((p)=>{- const morph = Object.entries(p.morphTargetDictionary).find(([_key,value])=>value==bind.index)- if(morph){- blendshapeNames.push(morph[0])- }- })-- return blendshapeNames- })- return blendshapes--}\ No newline at end of filediff --git a/character-studio/src/library/manifestDataManager.js b/character-studio/src/library/manifestDataManager.jsindex bfb46e4e6..5ab9937e7 100644--- a/character-studio/src/library/manifestDataManager.js+++ b/character-studio/src/library/manifestDataManager.js@@ -96,9 +96,9 @@ export class ManifestDataManager{};}- isGroupTraitRestrictedInAnyManifest(trait, groupTraitID){+ isGroupTraitRestrictedInAnyManifest(trait){for (const manifestData of this.manifestDataCollection){- const p = manifestData.manifestRestrictions.restrictionMaps[trait]?.isReverseBlendsh+ void manifestData.manifestRestrictions.restrictionMaps[trait]?.isReverseBlendsh}}@@ -159,7 +159,7 @@ export class ManifestDataManager{console.log(`Manifest with ID ${identifier} has been already loaded.`)return Promise.reject(new Error(`Manifest with ID ${identifier} has been already loaded.`));}- return new Promise(async (resolve, reject) => {+ return new Promise((resolve, reject) => {try{if (manifest) {// Create a CharacterManifestData instance based on the fetched manifest@@ -329,7 +329,8 @@ export class ManifestDataManager{return Promise.resolve();}else{- return new Promise(async (resolve) => {+ return new Promise((resolve, reject) => {+ (async () => {try{const traits = await manifestData(url, ignoreGroupTraits);resolve(traits);@@ -338,6 +339,7 @@ export class ManifestDataManager{console.log("an error ocurred while trying to load:", url);resolve(null);}+ })().catch(reject);});}}diff --git a/character-studio/src/library/merge-geometry.js b/character-studio/src/library/merge-geometry.jsindex ff6ff698c..626d92051 100644--- a/character-studio/src/library/merge-geometry.js+++ b/character-studio/src/library/merge-geometry.js@@ -81,28 +81,6 @@ export function cloneSkeleton(skinnedMesh) {// return newSkeleton;// }-function changeBoneHandedness(bone) {- console.log("isvrm0")- // Clone the bone and apply handedness change- const clone = bone.clone(false);-- // Reverse the X-axis scale to change handedness- const scale = clone.scale;- scale.x = -scale.x;-- // Reverse the rotation around the Y-axis to change handedness- const rotation = clone.rotation;- rotation.y = -rotation.y;-- // You might need to adjust the position as well depending on your specific use case.- // If the mesh is centered at the origin, this may not be necessary.- // If your mesh has been moved from the origin, you may need to adjust the position as well.- // clone.position.x = -clone.position.x;-- clone.position.set(0,0,0);-- return clone;-}function createMergedSkeleton(meshes, scale){/* user should be careful with naming convetions in custom bone names out from humanoids vrm definition,for example ones that come from head (to add hair movement), should start with vrm's connected bone@@ -110,9 +88,6 @@ function createMergedSkeleton(meshes, scale){this will avoid an error of not adding bones if they have they same name but are in different hierarchy locationtodo: add to a user guide how to name bones to avoid this error */const boneClones = new Map();- const zxNeg = new THREE.Vector3(-1,1,-1)- const bnWorldMatrix = new THREE.Matrix4();- const bnPosition = new THREE.Vector3();let index = 0;meshes.forEach(mesh => {diff --git a/character-studio/src/library/mint-utils.js b/character-studio/src/library/mint-utils.jsindex 10d3c94ab..5aad953a3 100644--- a/character-studio/src/library/mint-utils.js+++ b/character-studio/src/library/mint-utils.js@@ -5,7 +5,6 @@ import { SolanaManager } from "./solanaManager"import { Connection, Transaction } from "@solana/web3.js";// import { Connection, PublicKey } from '@solana/web3.js';// import { Metaplex } from '@metaplex-foundation/js';-import axios from "axios"const rpcKey = import.meta.env.VITE_HELIUS_KEY;const rpcUrl = `https://devnet.helius-rpc.com/?api-key=${rpcKey}`@@ -21,7 +20,6 @@ const validation_server = import.meta.env.VITE_VALIDATION_SERVER_URL;const PIN_ENDPOINT = '/api/pinning/pin'//const mintCost = 0.01-const chainId = "0x89";let tokenPrice;const manager = new SolanaManager();@@ -34,39 +32,6 @@ console.log(manager);-async function getContract(address) {- const contractAddress = address; // Loot NFT contract address- const tokenId = 1; // Replace with the desired token ID-- // ABI for a typical ERC721 contract (simplified)- const abi = [- "function tokenURI(uint256 tokenId) view returns (string)"- ];-- const key = await import.meta.env.ALCHEMY_API_KEY;- const defaultProvider = new ethers.AlchemyProvider('mainnet', key);-- //const defaultProvider = new ethers.providers.AlchemyProvider('mainnet', key);- // Use Ethereum mainnet provider- //const defaultProvider = ethers.getDefaultProvider('mainnet');- //const defaultProvider = new ethers.providers.StaticJsonRpcProvider('https://polygon-rpc.com/')- console.log(defaultProvider);- try {- // Connect to the contract- const contract = new ethers.Contract(contractAddress, abi, defaultProvider);- console.log("Contract instance:", contract);-- // Fetch the token URI (metadata URL)- const tokenURI = await contract.tokenURI(tokenId);- console.log("Token URI:", tokenURI);-- // Handle the metadata (your existing logic continues here)- } catch (error) {- console.error("Error fetching metadata:", error);- }-}--async function getTokenPrice(){if (tokenPrice != null)return tokenPrice@@ -102,7 +67,8 @@ export function fetchSolanaPurchasedAssets(walletAddress, delegateAddress, colleexport function buySolanaPurchasableAssets(merchantPublicKey, treeAddress, collectionName, amount, purchaseNFTs){- return new Promise(async(resolve, reject) => {+ return new Promise((resolve, reject) => {+ (async () => {const { solana } = window;console.log(window.solana)@@ -145,7 +111,7 @@ export function buySolanaPurchasableAssets(merchantPublicKey, treeAddress, colleconsole.error("Error requesting payment:", e.message);reject();}-+ })().catch(reject);});}@@ -206,7 +172,6 @@ export function fetchOwnedNFTs (walletAddress, network, collection){case 'solana':{console.warn("solana work in progress");return Promise.resolve(false);- return fetchFromMetaplex(walletAddress, collection);}default:{console.log("Unsupported Netwrok: " + walletAddress)@@ -251,27 +216,6 @@ const fetchFromOpensea = (walletAddress, chain, collection) => {}-const fetchFromMetaplex = (walletAddress, collection) =>{- console.log("work in progress");- // return new Promise((resolve, reject) => {- // const connection = new Connection('https://api.mainnet-beta.solana.com'); // Mainnet endpoint- // const metaplex = new Metaplex(connection);-- // const ownerPublicKey = new PublicKey(walletAddress);-- // metaplex.nfts().findAllByOwner({ owner: ownerPublicKey })- // .then(nfts => {- // console.log(collection);- // console.log(nfts);- // resolve(nfts); // Resolving with the NFTs data- // })- // .catch(error => {- // reject(error); // Rejecting the promise in case of an error- // });- // });-}--/*** Switches the active wallet to a specific blockchain and retrieves the wallet address.*@@ -281,7 +225,8 @@ const fetchFromMetaplex = (walletAddress, collection) =>{*/export function connectWallet(network) {console.log("connect wallet:", network);- return new Promise(async (resolve, reject) => {+ return new Promise((resolve, reject) => {+ (async () => {try {switch (network.toLowerCase()) {case 'ethereum':@@ -289,7 +234,7 @@ export function connectWallet(network) {if (!window.ethereum) {return reject(new Error('Ethereum wallet is not available.'));}-+const chainIdMap = {ethereum: '0x1', // Ethereum Mainnetpolygon: '0x89', // Polygon Mainnet@@ -299,7 +244,7 @@ export function connectWallet(network) {await window.ethereum.request({method: 'wallet_switchEthereumChain',params: [{ chainId: targetChain }],- })+ })const accounts = await window.ethereum.request({method: 'eth_requestAccounts',@@ -322,6 +267,7 @@ export function connectWallet(network) {} catch (error) {return reject(error);}+ })().catch(reject);});}@@ -531,7 +477,7 @@ export async function mintAsset(avatar, screenshot, model, name, needCheckOT){console.log("Mint success!")return "Mint success!";}- } catch (err) {+ } catch {//console.log("Public Mint failed! Please check your wallet.")return "Public Mint failed."}diff --git a/character-studio/src/library/spriteAtlasGenerator.js b/character-studio/src/library/spriteAtlasGenerator.jsindex 5a85860e6..ed9a28bfa 100644--- a/character-studio/src/library/spriteAtlasGenerator.js+++ b/character-studio/src/library/spriteAtlasGenerator.js@@ -24,7 +24,6 @@ export class SpriteAtlasGenerator {assetsLocation = "",animationsDirectory = "",backgroundColor = [1,1,1,1],- screenshotOffset,topFrameOffset = 0.1,bottomFrameOffset = 0.1,pixelStyleSize,@@ -55,8 +54,6 @@ export class SpriteAtlasGenerator {animationName,animationPath,framesNumber,- lookAtCamera,- expression,cameraPosition,cameraFrame,} = spriteInfo;diff --git a/character-studio/src/library/textureImageDataRenderer.js b/character-studio/src/library/textureImageDataRenderer.jsindex 30bd2dc15..bf1be3c0b 100644--- a/character-studio/src/library/textureImageDataRenderer.js+++ b/character-studio/src/library/textureImageDataRenderer.js@@ -43,7 +43,7 @@ export default class TextureImageDataRenderer {// if texture is null or undefined, create a texture only with clearColor (that is color type)const textures = getAsArray(texture)if (textures.length === 0) {- texture = getAsArray(TextureImageDataRenderer.createSolidColorTexture(clearColor, this.width, this.height))+ getAsArray(TextureImageDataRenderer.createSolidColorTexture(clearColor, this.width, this.height))}if (this.renderer == null) {@@ -150,7 +150,6 @@ export default class TextureImageDataRenderer {})this.quads.forEach((quad) => {this.sceneRTT?.remove(quad)- quad = null})this.materials.length = 0this.quads.length = 0diff --git a/character-studio/src/library/thumbnailsGenerator.js b/character-studio/src/library/thumbnailsGenerator.jsindex 6b9beaf78..8acda6f31 100644--- a/character-studio/src/library/thumbnailsGenerator.js+++ b/character-studio/src/library/thumbnailsGenerator.js@@ -26,7 +26,6 @@ export class ThumbnailGenerator {animationFrame,animationTime,backgroundColor = [1,1,1,0],- screenshotOffset,topFrameOffset = 0.1,bottomFrameOffset = 0.1,thumbnailsWidth = 128,@@ -75,8 +74,6 @@ export class ThumbnailGenerator {bottomBoneMaxVertex = false,topBoneName,topBoneMaxVertex = true,- groupTopOffset,- groupBotomOffset,cameraFrame,saveOnlyIDs} = thumbnailInfo;diff --git a/character-studio/src/library/utils.js b/character-studio/src/library/utils.jsindex 983edbae0..cca5e0b4f 100644--- a/character-studio/src/library/utils.js+++ b/character-studio/src/library/utils.js@@ -198,7 +198,7 @@ export async function getModelFromScene(modelScene,avatar, format = 'glb', skinCtruncateDrawRange: true,binary: true,forcePowerOfTwoTextures: false,- maxTextureSize: 1024 || Infinity+ maxTextureSize: 1024};const avatarCombined = await combine(modelScene,avatar,{ transparentColor: skinColor, scale:scale });@@ -381,20 +381,6 @@ export function getAtlasSize(value){}}-function disposeMesh(mesh){- if (mesh.isMesh){- mesh.geometry.userData.faceNormals = null;-- mesh.geometry.dispose();- if (mesh.parent) {- mesh.parent.remove(mesh);- }- if (mesh.userData.cancelMesh){- disposeMesh(mesh.userData.cancelMesh)- }- }-}-export function disposeVRM(vrm) {const model = vrm.scene;disposeData(vrm)@@ -660,6 +646,7 @@ export const renameVRMBones = (vrm) => {bones['leftUpperArm'].node.parent != bones['spine']?.node &&bones['leftUpperArm'].node.parent != bones['neck']?.node &&bones['leftUpperArm'].node.parent != bones['head']?.node ){+ /* noop */}{bones['leftShoulder'] = {node:bones['leftUpperArm'].node.parent}}@@ -671,6 +658,7 @@ export const renameVRMBones = (vrm) => {bones['rightUpperArm'].node.parent != bones['spine']?.node &&bones['rightUpperArm'].node.parent != bones['neck']?.node &&bones['rightUpperArm'].node.parent != bones['head']?.node ){+ /* noop */}{bones['rightShoulder'] = {node:bones['rightUpperArm'].node.parent}}