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

Toon vrms #76

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Toon vrms #76

wants to merge 5 commits into from

Conversation

0reo
Copy link
Contributor

@0reo 0reo commented Mar 4, 2022

prepare toon materials and store basic and toon materials for quality changing. depnds on #72 and webaverse/app#2512. Will remove draft status once they have been accepted

closes #74

@0reo
Copy link
Contributor Author

0reo commented Mar 11, 2022

disabled references to getGfxSettingJSON and accessing local storage so this can get in without waiting on webaverse/app#2512

@0reo 0reo marked this pull request as ready for review March 11, 2022 03:05
Copy link
Contributor

@avaer avaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of code problems.

In addition, can we remove all name references in this PR? Names should not be used for logic.

app.updateQuality = async () => {
// const quality = getGfxSettingJSON('character').details;
// return await _setQuality(quality, app)
const quality = JSON.parse(localStorage.getItem('GfxSettings'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unacceptable for Totum to read local storage, since totum can run with environments that have no storage.

This must go through API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why I had get/set gfxSettings in the metaversefile, which you asked me to remove into a settings.js file.
webaverse/app#2512 (comment)

await app.updateQuality();

//prep any outstanding meshes
//may not need this yet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then delete it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be immediately needed in the PR's for crunched and sprite meshes. I can delete it now, but it'll immediately be back in the next pr

app.skinnedVrm = skinnedVrmBase;
await _toonShaderify(skinnedVrmBase);
app.skinnedVrms['base'] = skinnedVrmBase;
app.skinnedVrm = skinnedVrmBase; //temporary support for webaverse code base until it's updated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I delete this, the webaverse app will break because it's currently referencing skinnedVrm when making avatars. We'll need to update the webaverse app to reference skinnedVrms, which will also cause it to break if this has not been merged yet.

base: {}
};
app.isToon = material => material[0] && material[0].isMToonMaterial;
app.isBasic = material => material.type == "MeshBasicMaterial" && material.name; //we're only changing named materials
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try not to base anything on THREE.js name, that is mostly for user convenience.


export default e => {
const physics = usePhysics();

const app = useApp();
app.appType = 'vrm';
app.active = 'base';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Active sounds like a boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Active is the mesh that corresponds to the users performance settings. this only has support for base and toon, but there will also be sprite and crunched. I can rename if you'd prefer something else

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The answer to "What is the app's .active?" sounds like a boolean to me.

return vrm;
};

const _prepVrm = (vrm) => {
//vrm.visible = false; //will need later
vrm.visible = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do this. If the VRM is invisible it is probably for good reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there will always be at least 2 vrms loaded, the base(high quality) vrm, and the crunched vrm. this defaults all the meshs to not visible to start, and the required meshes will be toggles accordingly.

app.add(vrm);
vrm.updateMatrixWorld();
_addAnisotropy(vrm, 16);
}

app.getActive = (_app = false) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a good function.

First of all it it's a getter that takes a parameter, which is bad.
Second, that parameter is not even consistent with the parameter of setActive.
Third, getActive sounds like a boolean. Is it active? But that is not what is returned here.
Fourth, the method is polymorphic and will return many different types.

Can we delete this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getActive is going to return the mesh that's corresponded with the current quality setting. this only has support for base(high quality) and toon(ultra quality), but there will also be sprite and crunched. I can rename for clarity, and remove the _app parameter so that only only 1 type is returned, and have the developer simply access .scene on their own.

@@ -93,25 +180,53 @@ export default e => {
const _cloneVrm = async () => {
const vrm = await parseVrm(arrayBuffer, srcUrl);
vrm.cloneVrm = _cloneVrm;
vrm.toonShaderify = _toonShaderify;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't expose this, it's internal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

app.isBasic = material => material.type == "MeshBasicMaterial" && material.name; //we're only changing named materials
app.setMaterial = (name, type, material) => app.materials[type][name] = material;

app.skinnedVrms = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't expose this, it's internal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

}

app.active = target;
!app.getActive().parent && _prepVrm(app.getActive());
Copy link
Contributor

@avaer avaer Mar 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very strange check. What's the point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the active mesh is not added to the scene, then prep it(which adds it to the scene)

@avaer
Copy link
Contributor

avaer commented Mar 11, 2022

Given the problems in this PR I recommend a redo. I would not start with this code.

@0reo 0reo marked this pull request as draft March 24, 2022 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vrm totum apps should create and store toonified materials
2 participants