-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stubbing out models and actually planning
- Loading branch information
1 parent
a91362f
commit 60a3fe2
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}); | ||
} | ||
} |