Skip to content

Commit

Permalink
Stubbing out models and actually planning
Browse files Browse the repository at this point in the history
  • Loading branch information
rhiannanberry committed Oct 9, 2020
1 parent a91362f commit 60a3fe2
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
Empty file added src/asset_loader.js
Empty file.
23 changes: 23 additions & 0 deletions src/models/avatar_base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// i think we're just gonna chuck all skinned meshes into this bitch and tolggle visibility
// then for export, clone and then delete unselected parts
export default class AvatarBase {
//is the singular, base scene that will be ground truth for skeleton, animations, and material
constructor(scene) {
//make sure excess skinned meshes are removed
this._scene = scene;
this._partLists = [];
}

addPartList(list) {
this._partLists.push(list);
this._scene.children[0].children[1].push(...(list.skinnedMeshes));
}

exportAvatar() {
//need to clone this._scene
//flatten materials from each part list together
//delete all skinned meshes but 1 to use as base
//merge buffer geometry all of them and put in skinned mesh
//apply flattened material to that skinned mesh
}
}
52 changes: 52 additions & 0 deletions src/models/avatar_part_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
export default class AvatarPartList {
//Maybe extend this for the actual parts? idk
//contains the whole list of options for the given part
/*
list --> many part
list --> one material, shared across part
*/
constructor(skinnedMeshes, customMaterials) {
this._skinnedMeshes = skinnedMeshes;
this._customMaterials = customMaterials;
this._selectedIndex = 0;
this._setSelected();
this._applyMaterials();
}

get selectedIndex() {
return this._selectedIndex;
}

get selected() {
return this._skinnedMeshes[this._selectedIndex];
}

get material() {
return this._material; //should return custom mat object?
}

get skinnedMeshes() {
return this._skinnedMeshes;
}

set selectedIndex(index) {
this._selectedIndex = index;
this._setSelected();
}

_setSelected() {
this._skinnedMeshes.forEach( (mesh, index) => {
mesh.visible = index == this._selectedIndex;
});
}

_applyMaterials() {
this._skinnedMeshes.forEach( mesh => {
mesh.material = this._customMaterials;
mesh.geometry.clearGroups();
for (var i = 0; i < this._customMaterials.length; i++) {
mesh.geometry.addGroup(0, Infinity, i);
}
});
}
}

0 comments on commit 60a3fe2

Please sign in to comment.