M2s no longer overuse THREE.SkinnedMesh and skinned materials. M2s without bone animations now create regular THREE.Mesh objects, which do not incur as much cost in the render loop.
Texture units (which represent render passes in the actual World of Warcraft client) are now given separate materials, 1:1 with the number of units. When submeshes are created for an M2, all applicable texture units are turned into child SkinnedMesh (or, if not animated, vanilla Mesh) objects, with the aforementioned material attached. As best I can tell, this should ensure proper drawing order between units.
M2 materials are now full blown ShaderMaterials.
Initial work on blending together multiple textures within individual texture units. Currently, only a few shader modes have been implemented. It's still a bit unclear how the game expects different modes to be applied, and what the precise shader logic for each mode should be.
Added vertex normals. Normals are used to determine light intensity in the diffuse lighting fragment shader logic.
Added fog, diffuse, and ambient lighting support to M2s. Values are currently hardcoded into the uniforms on the M2Material class, and will eventually need to migrate to some kind of global lighting manager.
A root mesh is now created to serve as the appropriate parent for root bones. Root bones are no longer pointlessly reassigned across all submeshes. The root mesh is bound to the skeleton.
Submeshes are placed as children in the root mesh when created.
The M2 constructor is now broken up across functions that handle creating the skeleton, geometry, root mesh, and submeshes.
The use of data and skinData within the M2 class is now limited to just the constructor and functions called in the constructor.
Billboarding now makes use of the skin property of the bone to find the appropriate parent to pull the model view matrix from.
When M2s that allow instancing are cloned, their geometries and materials are copied from the original M2. This helps alleviate the burden placed on the GPU by excessive amounts of geometries.
I'd like to take a look at sharing submesh materials next-- that might cut out a decent chunk of VRAM usage from things that are commonly cloned, such as trees.
THREE.SkinnedMesh
and skinned materials. M2s without bone animations now create regularTHREE.Mesh
objects, which do not incur as much cost in the render loop.SkinnedMesh
(or, if not animated, vanillaMesh
) objects, with the aforementioned material attached. As best I can tell, this should ensure proper drawing order between units.ShaderMaterial
s.M2Material
class, and will eventually need to migrate to some kind of global lighting manager.data
andskinData
within the M2 class is now limited to just the constructor and functions called in the constructor.skin
property of the bone to find the appropriate parent to pull the model view matrix from.