From cb5ae69e408074b78460c735f126aea50f4b9878 Mon Sep 17 00:00:00 2001 From: memelotsqui Date: Mon, 30 Oct 2023 22:51:40 -0600 Subject: [PATCH 1/7] remove only vrm1 warning --- src/components/Selector.jsx | 40 +++++++++++-------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/src/components/Selector.jsx b/src/components/Selector.jsx index aecd0637..636d46fb 100644 --- a/src/components/Selector.jsx +++ b/src/components/Selector.jsx @@ -60,7 +60,6 @@ export default function Selector({confirmDialog, templateInfo, animationManager, const [, setLoadPercentage] = useState(1) const [restrictions, setRestrictions] = useState(null) const [currentTrait, setCurrentTrait] = useState(new Map()); - const [vrm1Warn, setVrm1Warn1] = useState(true); const updateCurrentTraitMap = (k,v) => { setCurrentTrait(currentTrait.set(k,v)); @@ -181,37 +180,22 @@ export default function Selector({confirmDialog, templateInfo, animationManager, effectManager.setTransitionEffect('switch_item'); loadOptions([option], false, false, false).then((loadedData)=>{ URL.revokeObjectURL(url); - if (loadedData[0].models[0]?.userData?.gltfExtensions?.VRMC_vrm){ - let newAvatar = {}; - loadedData.map((data)=>{ - newAvatar = {...newAvatar, ...itemAssign(data)} - }) - const finalAvatar = {...avatar, ...newAvatar} - setTimeout(() => { - if (Object.keys(finalAvatar).length > 0) { - cullHiddenMeshes(finalAvatar) - } - }, effectManager.transitionTime); - setAvatar(finalAvatar) - } - else{ - - console.log("Only vrm1 file supported") - } + let newAvatar = {}; + loadedData.map((data)=>{ + newAvatar = {...newAvatar, ...itemAssign(data)} + }) + const finalAvatar = {...avatar, ...newAvatar} + setTimeout(() => { + if (Object.keys(finalAvatar).length > 0) { + cullHiddenMeshes(finalAvatar) + } + }, effectManager.transitionTime); + setAvatar(finalAvatar) }) } const promptUpload = async () => { - if (vrm1Warn){ - confirmDialog("Supports only VRM1 files", (val)=>{ - setVrm1Warn1(!val); - if (val) - uploadTrait() - }) - } - else{ - uploadTrait(); - } + uploadTrait(); } const uploadTrait = async() =>{ From b179062983763732443b36910722525563047411 Mon Sep 17 00:00:00 2001 From: memelotsqui Date: Mon, 30 Oct 2023 23:02:39 -0600 Subject: [PATCH 2/7] remove promp-tupload and set only upload --- src/components/Selector.jsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/components/Selector.jsx b/src/components/Selector.jsx index 636d46fb..177924d9 100644 --- a/src/components/Selector.jsx +++ b/src/components/Selector.jsx @@ -194,10 +194,6 @@ export default function Selector({confirmDialog, templateInfo, animationManager, }) } - const promptUpload = async () => { - uploadTrait(); - } - const uploadTrait = async() =>{ var input = document.createElement('input'); input.type = 'file'; @@ -811,7 +807,7 @@ export default function Selector({confirmDialog, templateInfo, animationManager,
{promptUpload()}}> + onClick={uploadTrait}>
Upload
From f64dcd5896c193eb1e069349fb256eabaff25d10 Mon Sep 17 00:00:00 2001 From: memelotsqui Date: Mon, 30 Oct 2023 23:11:27 -0600 Subject: [PATCH 3/7] change function parameter from file to url --- src/components/Selector.jsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/Selector.jsx b/src/components/Selector.jsx index 177924d9..a39d15f8 100644 --- a/src/components/Selector.jsx +++ b/src/components/Selector.jsx @@ -29,7 +29,7 @@ THREE.BufferGeometry.prototype.computeBoundsTree = computeBoundsTree; THREE.BufferGeometry.prototype.disposeBoundsTree = disposeBoundsTree; THREE.Mesh.prototype.raycast = acceleratedRaycast; -export default function Selector({confirmDialog, templateInfo, animationManager, blinkManager, lookatManager, effectManager}) { +export default function Selector({confirmDialog, uploadVRMURL, templateInfo, animationManager, blinkManager, lookatManager, effectManager}) { const { avatar, setAvatar, @@ -70,9 +70,12 @@ export default function Selector({confirmDialog, templateInfo, animationManager, useEffect(() => { setRestrictions(getRestrictions()); - },[templateInfo]) + useEffect(()=>{ + console.log(uploadVRMURL); + },[uploadVRMURL]) + const getRestrictions = () => { const traitRestrictions = templateInfo.traitRestrictions @@ -166,10 +169,9 @@ export default function Selector({confirmDialog, templateInfo, animationManager, },[selectedOptions]) - const loadCustom = (file) => { - const url = URL.createObjectURL(file); + const loadCustom = (url) => { + const option = { - item:{ id:"custom_" + currentTraitName, name:"Custom " + currentTraitName, @@ -202,7 +204,8 @@ export default function Selector({confirmDialog, templateInfo, animationManager, input.onchange = e => { var file = e.target.files[0]; if (file.name.endsWith(".vrm")){ - loadCustom(file) + const url = URL.createObjectURL(file); + loadCustom(url) } } input.click(); From 53c7c9b0aab280dc1136d191c7cd7d064dfacb7f Mon Sep 17 00:00:00 2001 From: memelotsqui Date: Mon, 30 Oct 2023 23:12:46 -0600 Subject: [PATCH 4/7] validate correct vrmurl --- src/components/Selector.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Selector.jsx b/src/components/Selector.jsx index a39d15f8..dc9f45c4 100644 --- a/src/components/Selector.jsx +++ b/src/components/Selector.jsx @@ -73,7 +73,12 @@ export default function Selector({confirmDialog, uploadVRMURL, templateInfo, ani },[templateInfo]) useEffect(()=>{ - console.log(uploadVRMURL); + if (uploadVRMURL != null){ + if (uploadVRMURL != ""){ + console.log(uploadVRMURL); + loadCustom(uploadVRMURL); + } + } },[uploadVRMURL]) const getRestrictions = () => { From c2049caf8096866fd71c7efe54e6fa692e04cf8a Mon Sep 17 00:00:00 2001 From: memelotsqui Date: Mon, 30 Oct 2023 23:15:10 -0600 Subject: [PATCH 5/7] Appearance set VRM when drag and drop --- src/pages/Appearance.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pages/Appearance.jsx b/src/pages/Appearance.jsx index 132c2d2a..cd129f91 100644 --- a/src/pages/Appearance.jsx +++ b/src/pages/Appearance.jsx @@ -43,6 +43,7 @@ function Appearance({ const [jsonSelectionArray, setJsonSelectionArray] = React.useState(null) const [uploadTextureURL, setUploadTextureURL] = React.useState(null) + const [uploadVRMURL, setUploadVRMURL] = React.useState(null) const next = () => { !isMute && playSound('backNextButton'); @@ -97,6 +98,10 @@ function Appearance({ const path = URL.createObjectURL(file); setUploadTextureURL(path); } + const handleVRMDrop = (file) =>{ + const path = URL.createObjectURL(file); + setUploadVRMURL(path); + } const handleFilesDrop = async(files) => { const file = files[0]; @@ -107,6 +112,9 @@ function Appearance({ if (file && (file.name.toLowerCase().endsWith('.png') || file.name.toLowerCase().endsWith('.jpg'))) { handleImageDrop(file); } + if (file && file.name.toLowerCase().endsWith('.vrm')) { + handleVRMDrop(file); + } const filesArray = Array.from(files); const jsonDataArray = []; @@ -188,6 +196,7 @@ function Appearance({ confirmDialog={confirmDialog} jsonSelectionArray={jsonSelectionArray} uploadTextureURL = {uploadTextureURL} + uploadVRMURL = {uploadVRMURL} />
Date: Mon, 30 Oct 2023 23:15:35 -0600 Subject: [PATCH 6/7] update esitor to pass url --- src/components/Editor.jsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/Editor.jsx b/src/components/Editor.jsx index 6422910c..d3c6014d 100644 --- a/src/components/Editor.jsx +++ b/src/components/Editor.jsx @@ -21,7 +21,7 @@ import MenuTitle from "./MenuTitle" import { setTextureToChildMeshes } from "../library/utils" -export default function Editor({uploadTextureURL,confirmDialog,animationManager, blinkManager, lookatManager, effectManager, jsonSelectionArray}) { +export default function Editor({uploadTextureURL, uploadVRMURL,confirmDialog,animationManager, blinkManager, lookatManager, effectManager, jsonSelectionArray}) { const { currentTraitName, setCurrentTraitName, @@ -123,7 +123,14 @@ export default function Editor({uploadTextureURL,confirmDialog,animationManager,
- + From d77fc8b26ad7a73e1275a05c8011c9aa8b1a9eb8 Mon Sep 17 00:00:00 2001 From: memelotsqui Date: Mon, 30 Oct 2023 23:23:19 -0600 Subject: [PATCH 7/7] validate a trait is selected --- src/components/Selector.jsx | 50 ++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/components/Selector.jsx b/src/components/Selector.jsx index dc9f45c4..c19ed812 100644 --- a/src/components/Selector.jsx +++ b/src/components/Selector.jsx @@ -175,30 +175,34 @@ export default function Selector({confirmDialog, uploadVRMURL, templateInfo, ani },[selectedOptions]) const loadCustom = (url) => { - - const option = { - item:{ - id:"custom_" + currentTraitName, - name:"Custom " + currentTraitName, - directory:url - }, - trait:templateInfo.traits.find((t) => t.name === currentTraitName) - } - effectManager.setTransitionEffect('switch_item'); - loadOptions([option], false, false, false).then((loadedData)=>{ - URL.revokeObjectURL(url); - let newAvatar = {}; - loadedData.map((data)=>{ - newAvatar = {...newAvatar, ...itemAssign(data)} + if (currentTraitName){ + const option = { + item:{ + id:"custom_" + currentTraitName, + name:"Custom " + currentTraitName, + directory:url + }, + trait:templateInfo.traits.find((t) => t.name === currentTraitName) + } + effectManager.setTransitionEffect('switch_item'); + loadOptions([option], false, false, false).then((loadedData)=>{ + URL.revokeObjectURL(url); + let newAvatar = {}; + loadedData.map((data)=>{ + newAvatar = {...newAvatar, ...itemAssign(data)} + }) + const finalAvatar = {...avatar, ...newAvatar} + setTimeout(() => { + if (Object.keys(finalAvatar).length > 0) { + cullHiddenMeshes(finalAvatar) + } + }, effectManager.transitionTime); + setAvatar(finalAvatar) }) - const finalAvatar = {...avatar, ...newAvatar} - setTimeout(() => { - if (Object.keys(finalAvatar).length > 0) { - cullHiddenMeshes(finalAvatar) - } - }, effectManager.transitionTime); - setAvatar(finalAvatar) - }) + } + else{ + console.log("Please select a trait first"); + } } const uploadTrait = async() =>{