Skip to content

Toon vrms - #76

Draft
0reo wants to merge 5 commits into
webaverse:mainfrom
0reo:toon-vrms
Draft

Toon vrms#76
0reo wants to merge 5 commits into
webaverse:mainfrom
0reo:toon-vrms

Conversation

@0reo

@0reo 0reo commented Mar 4, 2022

Copy link
Copy Markdown
Contributor

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

0reo commented Mar 11, 2022

Copy link
Copy Markdown
Contributor Author

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

@avaer avaer left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread type_templates/vrm.js Outdated
app.updateQuality = async () => {
// const quality = getGfxSettingJSON('character').details;
// return await _setQuality(quality, app)
const quality = JSON.parse(localStorage.getItem('GfxSettings'));

Copy link
Copy Markdown
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
Copy Markdown
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)

Comment thread type_templates/vrm.js Outdated
await app.updateQuality();

//prep any outstanding meshes
//may not need this yet

Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread type_templates/vrm.js
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
Copy Markdown
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
Copy Markdown
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.

Comment thread type_templates/vrm.js
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
Copy Markdown
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.

Comment thread type_templates/vrm.js

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread type_templates/vrm.js

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

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread type_templates/vrm.js
_addAnisotropy(vrm, 16);
}

app.getActive = (_app = false) => {

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread type_templates/vrm.js
const _cloneVrm = async () => {
const vrm = await parseVrm(arrayBuffer, srcUrl);
vrm.cloneVrm = _cloneVrm;
vrm.toonShaderify = _toonShaderify;

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok

Comment thread type_templates/vrm.js
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure

Comment thread type_templates/vrm.js Outdated
}

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

@avaer avaer Mar 11, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

avaer commented Mar 11, 2022

Copy link
Copy Markdown
Contributor

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